Answers for "attribute value in jquery"

8

jquery attr

$( 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"
});
Posted by: Guest on May-16-2020
0

jQuery( "[attribute|='value']" )

/* Description: Selects elements that 
have the specified attribute with a value either equal to a given string or
starting with that string followed by a hyphen (-). */
<body>
 
<a href="example.html" hreflang="en">Some text</a> <!-- will select this -->
<a href="example.html" hreflang="en-UK">Some other text</a> <!-- will select this -->
<a href="example.html" hreflang="english">will not be outlined</a> <!-- not this -->
 
<script>
$( "a[hreflang|='en']" ).css( "border", "3px dotted green" );
</script>
 
</body>
</html>
Posted by: Guest on August-22-2021

Code answers related to "attribute value in jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language