Answers for "find attr value in jquery"

4

jquery attribute selector

Syntax
$("[attribute|='value']")

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("p[title|='Tomorrow']").css("background-color", "yellow");});  
</script>
</head>
<body>

<p title="Tomorrow">This is a paragraph.</p>
<p title="tomorrow">This is a paragraph.</p>
<p title="Tom">This is a paragraph.</p>
<p title="See You Tomorrow">This is a paragraph.</p>
<p title="Tomorrow-the day after today">This is a paragraph.</p>

<p>This selector selects all elements with a title attribute value equal to 'Tomorrow', or starting with 'Tomorrow' followed by a hyphen.</p>

</body>
</html>
Posted by: Guest on April-22-2020
8

get attribute value jquery

var some_var = $( some_jquery_selector ).attr( 'some_attribute_name' );
Posted by: Guest on March-20-2020
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

Code answers related to "Javascript"

Browse Popular Code Answers by Language