Chrome Extension

Add class to element jQuery

$("div").addClass("hello");

//ADD CLASS ON CLICK
$("button").click(function() {
    $("div").addClass("hello");
});

.addClass() method is used in jQuery to add a CSS class on HTML Element. In the above example, we have added a class named 'hello' on the div element and also on button click.


Search Index Data (The code snippet can also be found with below search text)

.addClass() jQuery
Was this helpful?
0 Comments
Never leave your website again in search of code snippets by installing our chrome extension.
Open Code Manager