Like this - $(document).ready(function() ) Īs you can see in the above code, I used jQuery css() method to add extra CSS on the button click. To change the color of a div or button, you have to use the ready function of jquery. How to change the color of a button or div using the jQuery library? In the above code, you can see, I have created another my_btn2 class and added this class on button click using a JavaScript function.Įxecute the above code and click on the My button and you will see the effect.Ĭhanging the color of a button or div is much easier using css() method in jQuery.You can add extra CSS attributes and properties using jQuery css method. You have to create a new CSS class before adding a new class using the jQuery addClass() function. If you want to change the color of the HTML button by clicking on the same or different button then you should create onClick event on any button.Create a function and add a new class by jQuery addClass() method. This is one of the finest method on jquery to change the CSS class of div blocks, span, buttons, forms fields, etc. the addClass() method or function is used to change or add a new class to the button. You can easily change color using the jQuery library with addClass() method.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |