Lukas Lukas - 6 months ago 22
HTML Question

HTML Value finding

I know that "this.value" can get the value of the

<option>
tag:

<select name="users" onchange="showUser(this.value)">
<option value="">Select a person:</option>
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Joseph Swanson</option>
<option value="4">Glenn Quagmire</option>
</select>


But how to get a value (value="IE") from the
<a>
tag, because this doesn't work:

<a href="#" value="IE" onclick="showUser(this.value)">Click</a>

Answer

unfortunately the link tag <a> don't have an attribute value.

What i can advice you if you don't want change your function showUser is to do something near the following :

    <a href="#"><button id="myButton" value="IE" onclick="showUser(this.value)"></button></a>

then to make appear the button like a link you can try a CSS solution like the following :

#myButton {
    border:none;
    background:none;
    color:blue;
    text-decoration:underline;

}

#myButton:hover {
    color:purple;
    cursor:pointer;
}
Comments