Chrome Extension

Add class to element jQuery

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

//ADD CLASS ON CLICK
$("button").click(function() {
    $("div").addClass("hello");
});
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

.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
Join Devsheet Ask a Question