Toggleclass in jQuery example with click event

In the following web example we have two input radio with id respectively single and list that allows us to choose between two options, a div with id my_header and a list with id my_list with 3 options each with a different class that sets by default different color styles to the text that contains them.

With jQuery we create the following options:

  • Clicking on the input radio with id single executes a function that selects the div with id my_header and through the toggleClass function activates or deactivates the set-color1 and set-font styles depending on its state.
  • Clicking on the input radio with id list executes a function that selects the list with id my_list and each element li, through the toggleClass function executes a function that activates or deactivates the set-color styles and its successive index value starting from 0.
Comments

PHP Captcha


Interesting Articles