Chrome Extension

Get and set attribute value jQuery

//GET ATTRIBUTE VALUE
$("div").attr("data-number");

//SET ATTRIBUTE VALUE
$("div").attr("data-number", "20");
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

.attr() method in jQuery is used to get and set attribute value to an HTML element. We are setting the "data-number" attribute value to "20" by using snippet code.

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

.attr() jQuery
Was this helpful?
0 Comments
Join Devsheet Ask a Question