setAttribute Method

Sets the value of the specified attribute.

Syntax

object.setAttribute(sAttName, vAttrValue)

Parameters

sAttName Required. String that specifies the name of the attribute.
vAttrValue Required. Variant that specifies the String, number, or Boolean to assign to the attribute.

Return Value

No return value.

Example

The following example shows how to use the setAttribute method to change the value of an attribute of a ToolbarButton.


<HTML xmlns:mytb>
<?import namespace="mytb" implementation="toolbar.htc">
<HEAD>
<SCRIPT>
function fnChangeStyle()
{
    var oButton = event.srcNode;
    oButton.setAttribute("text", "I was clicked!");
}
</SCRIPT>
</HEAD>

<BODY>

<mytb:TOOLBAR STYLE="display:inline" onbuttonclick="fnChangeStyle();" ID="oToolBar">

<mytb:TOOLBARLABEL TEXT="BUTTON:" />
<mytb:TOOLBARBUTTON IMAGEURL="/workshop/graphics/tool-mail.gif" 
TEXT="Click Me" 
DEFAULTSTYLE="background-color:#FFFFFF; color:#000000"
HOVERSTYLE="background-color:#FFFFCC; color:#666666"
SELECTEDSTYLE="color:#FF0033; border:1px solid #000000"
 />
 
</mytb:TOOLBAR> 

</BODY>
</HTML>

Code example: https://samples.msdn.microsoft.com/workshop/samples/webcontrols/toolbar/setAttribute.htm

Applies To

TAB, TABSEPARATOR, TOOLBARBUTTON, TOOLBARCHECKBUTTON, TOOLBARCHECKGROUP, TOOLBARDROPDOWNLIST, TOOLBARLABEL, TOOLBARSEPARATOR, TOOLBARTEXTBOX, TREEVIEW, TREENODE, TREENODETYPE

See Also

Internet Explorer WebControls, About the TabStrip WebControl, About the Toolbar WebControl, About the TreeView WebControl, DEFAULTSTYLE, HOVERSTYLE, orientation, selectedIndex, SELECTEDSTYLE, SEPDEFAULTIMAGEURL, SEPDEFAULTSTYLE, SEPHOVERIMAGEURL, SEPHOVERSTYLE, SEPSELECTEDIMAGEURL, SEPSELECTEDSTYLE, TABDEFAULTSTYLE, TABHOVERSTYLE, TABSELECTEDSTYLE, TARGETID, FORCESELECTION, MAXLENGTH, SELECTED, CHECKBOX, CHECKED, CHILDTYPE, EXPANDABLE, EXPANDED, EXPANDEDIMAGEURL, expandLevel, IMAGEURL, NAVIGATEURL, selectExpands, SELECTEDIMAGEURL, showLines, showPlus, systemImagesPath, TARGET, TREENODESRC, treeNodeTypeSrc, TREENODEXSLTSRC, TYPE