Saturday, November 17, 2012

javascript – How to keep button active after press with jQuery

I\’ve seen some very similar questions floating around but haven\’t been able to find the answer I\’m looking for. I\’ve already determined a work-around but would like to know the proper way to perform the task.


What I desire is to click the button and have the active state stay persistent. The next click will toggle the state and that is desired. What I really need to know is how to address the uiButton:active state.


HTML:



<input type=\'button\' class=\'uiButton\' id=\'testbutton\' value=\'testValue\'>


CSS:



.uiButton{
background-color: red;
}

.uiButton:active{
background-color:blue;
}


Javascript/jQuery:



$(\'.uiButton\').click(function() {
$(this).toggleClass(//active state);
});






Rating: 1 out of 5 based on 4 ratings



The post javascript – How to keep button active after press with jQuery appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/javascript-how-to-keep-button-active-after-press-with-jquery.html

No comments:

Post a Comment