Answers for "get element by attribute 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

name selector jquery

$('td[name ="tcol1"]')   // matches exactly 'tcol1'
$('td[name^="tcol"]' )   // matches those that begin with 'tcol'
$('td[name$="tcol"]' )   // matches those that end with 'tcol'
$('td[name*="tcol"]' )   // matches those that contain 'tcol'
Posted by: Guest on March-16-2020
3

find element with data attribute jquery

$("ul").find(`[data-slide='${current}']`)
Posted by: Guest on October-20-2020
8

get attribute value jquery

var some_var = $( some_jquery_selector ).attr( 'some_attribute_name' );
Posted by: Guest on March-20-2020
1

jquery show hide based on data attribute

$('form')
        .children()
        .filter(function(){
            return $(this).data('show') === 'pro';
        })
        .show();
$('form')
         .children()
         .filter(function(){
             return $(this).data('show') === 'home';
         })
         .hide();
Posted by: Guest on April-29-2020
0

jquery get element attribute

$( "div" ).data( "role" ) === "page";
$( "div" ).data( "lastValue" ) === 43;
$( "div" ).data( "hidden" ) === true;
$( "div" ).data( "options" ).name === "John";
Posted by: Guest on June-10-2021

Code answers related to "get element by attribute jquery"

Code answers related to "Javascript"

Browse Popular Code Answers by Language