jQuery add css, add html element With Examples

jQuery add method can be used to add elements, selectors or html to the matched elements.

jQuery add()

jQuery add() method is very useful if you want to apply any jQuery function or add CSS to DOM elements in HTML.

Below example shows how we can use add() to apply css styles to ‘table’, ‘p’ and ‘li’ DOM elements in a single line. Otherwise we had to apply styles on each element one by one. It also shows how can we add HTML to any DOM element.

jQuery add css – Try it Yourself

Here are the screenshots of HTML page when we click on the button multiple times.

jquery-add-1

After clicking on “Add Style” button for first time.

jquery-add-1

After clicking on “Remove Style” button for first time.

jquery-add-1

By admin

Leave a Reply