Chrome Extension

Get and set attribute value jQuery

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

//SET ATTRIBUTE VALUE
$("div").attr("data-number", "20");

.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
Never leave your website again in search of code snippets by installing our chrome extension.
Open Code Manager