### Set and Get HTML Tag Property

Examples of setting or getting HTML tag properties.
Set the URL of a Link Tag
This is done by setting the property HREF in the link tag.
HTML define the link
Visit Reference
B4J Code set the link
To set the link, use the SetProp method of the jQueryElement
`Sub Class_Globals
Private reference As JQueryElement
Set the property
dim referenceurl as string = "http://reference.html",
reference.SetProp("href", referenceurl)
Note
Just as an FYI, the same can be achieved by JavaScrip:
var a = document.getElementById('reference');
a.href = referenceurl;
Get the state of a Checkbox Tag
This is done by reading the property checked.
HTML define the Checkbox
Note the example uses w3.css classes.
<input class="w3-check" type="checkbox" checked="checked" id="timeoptiondlgmessage">
B4J Code get the state
Check if the include time option is selected. This is done by reading the property checked.
`Sub Class_Globals
Private timeoptiondlgmessage As JQueryElement
...
Dim btime As Boolean = timeoptiondlgmessage.GetProp("checked").Value
If btime Then
...
Note
To set the checked state, use SetProp
timeoptiondlgmessage.GetProp("checked", true)
Set the Class color for an Alert Modal Dialog
This example uses a w3.css modal dialog to show an alert by setting the class w3-panel with a color.
See www.w3schools.com/w3css/w3css_alerts.asp
HTML define the Dialog
The class w3-panel gets an ID, which is used to set the property class="w3-panel w3-color".
The default is .
<!-- MODAL DIALOG POPUPMESSAGESHOW BEGIN -->
<div id="dlgpopupmessageshow" class="w3-modal">
<div class="w3-modal-content">
<div class="w3-panel w3-blue" id="dlgpopupmessagetype">
<span onclick="document.getElementById('dlgpopupmessageshow').style.display='none'" class="w3-closebtn">×</span>
<p id="popupmessage"></p>
</div>
</div>
</div>
<!-- MODAL DIALOG POPUPMESSAGESHOW END -->
B4J Code to set the color of the w3-class
Define the dialog type as jqueryelement.
`Sub Class_Globals
Private dlgpopupmessagetype As JQueryElement
...
Set the color of the alert to red.
dlgpopupmessagetype.SetProp("class", "w3-panel w3-red")
```

Changed: 2018-06-07 09:28, Category: WebApps, File: T6C277M2074.htm, ID: 2074