1$( some_item ).attr( "id", "some-id" );
2// for setting multiple attributes, it's similar to the css() property. However, quotes are not always required for attr()
3$( some_item ).attr({
4 id: "some-id",
5 // or others.
6 title: "Opens in a new window",
7 // attributes which contain dash(-), should be covered in quotes.
8 "data-value": "internal link"
9});
1$( "div" ).data( "role" ) === "page";
2$( "div" ).data( "lastValue" ) === 43;
3$( "div" ).data( "hidden" ) === true;
4$( "div" ).data( "options" ).name === "John";
5
1<div data-role="page" data-last-value="43" data-hidden="true" data-options='{"name":"John"}'></div>
2