My drop down List to select particular value-
You ar creating a nodeList
(a special array of Nodes) using getElementsByClassName
. Alternatively you can use document.querySelector
, which returns the first element with className .catlink
:
function showDiv( discselect ) {
if( discselect === 1) {
document.querySelector(".catlink").innerHTML = "aaaaaaqwerty";
}
}
document.getElementsByClassName("catlink")
is selecting all the elements in webpage as array therefore you have to use [0]
function showDiv( discselect )
{
if( discselect === 1)
{
alert(discselect); // This is alerting fine
document.getElementsByClassName("catlink")[0].innerHTML = "aaaaaaqwerty"; // Now working
}
}