get attribute value jquery
/* html */
<a data-id="123">link</a>
/* js */
$(this).attr("data-id") // returns string "123"
$(this).data("id") // returns number 123 (jQuery >= 1.4.3 only)var some_var = $( some_jquery_selector ).attr( 'some_attribute_name' );$input.attr("attributeName", "attributeValue");$( some_item ).attr( "id", "some-id" );
// for setting multiple attributes, it's similar to the css() property. However, quotes are not always required for attr()
$( some_item ).attr({
id: "some-id",
// or others.
title: "Opens in a new window",
// attributes which contain dash(-), should be covered in quotes.
"data-value": "internal link"
});
Also in JavaScript:
- how to concatenate strings javascript
- how to get file extension in javascript last index
- loop json object android java
- angular get current route
- javascrip check if string contains substring
- javascript range of integers
- (node:2496) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
- angular submit form programmatically
- display none in jquery
- flutter betterplayer get aspect ratio
- how to check string uppercase or lowersace using regex javascript
- datetime to date javascript
- javascript lowercase string
- add jquery in js
- socket emit to specific room using nodejs socket.io
- dart lambda expression
- how to get a value into a react component
- angular.min.js version
- if isset handlebars js
- créer composant react
- allow cors express
- rxjs que recibe como parametro un observable
- javascript template literals
- high level components react