Chrome Extension

Add class to element jQuery

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

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

Do you know, you can create and search your own code snippets on Devsheet. Store your code on cloud using devsheet and search using its chrome extension. Is it look cool?

.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.