javascript - Add mouseover to all buttons on a page -


is there way add mouseover/mouseout css class change buttons on page through, example, javascript in page header, without having give each individual button own onmouseover , onmouseout events? seems inefficient have add every single button on of pages:

onmouseover="javascript:this.classname='ui-state-hover';" onmouseout="javascript:this.classname='ui-state-default';" 

there must easier way this!

give elements class , go this:

window.onload = function(){     var elms = document.getelementsbytagname('input');      // search element class myclass     (var = 0; < elms.length; i++){       if (elms[i].getattribute('class') === 'myclass'){          elms[i].onmouseover = function(){           this.classname='ui-state-hover'         }          elms[i].onmouseout = function(){           this.classname='ui-state-default'         }        }     } } 

just apply class myclass input boxes.

with jquery:

$(function(){   $('.myclass').hover(function(){     $(this).removeclass().addclass('ui-state-hover');   }, function(){     $(this).removeclass().addclass('ui-state-default');   }); }); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -