I've set up a menu bar on the top of my website with 4-5 asp.net buttons that are located in the master page. My goal is to have all the buttons change when hovered over, so I tried assigning events using a loop like this:
function pageLoad() {
var buttons = document.getElementsByClass("headerButton");
for (i = 0; i < buttons.length; i++) {
var b = buttons[i];
b.onmouseover = function (element) {
return function () {
element.style.fontWeight = "bold";
}
} (b);
b.onmouseout = function (element) {
return function () {
element.style.fontWeight = "normal";
}
} (b);
}
Unfortunately, this method only works on content pages. Since Page_Load doesn't trigger on the master page, placing this code there yields no results. Does anyone know the correct way to achieve what I'm aiming for?