Answers for "how to attribute value in jquery"

3

jquery add attribute

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Adding Attribute to HTML Element</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
    $(document).ready(function(){
        $(".add-attr").click(function(){            
            $('input[type="checkbox"]').attr("checked", "checked");
        });
    });
</script> 
</head>
<body>
    <button type="button" class="add-attr">Select Checkbox</button>
    <input type="checkbox"> 
</body>
</html>
Posted by: Guest on March-13-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 "how to attribute value in jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language