how to Script the hover and click states ?

how to Script the hover and click states ?

     I don't know where to put the hover code as for the buttons to interact while i hover over them 

where should I put this code ? 

.hover( function(){ $(this).addClass("ui-state-hover"); }, function(){ $(this).removeClass("ui-state-hover"); } 

)  Thanks !