Amit D has Published 118 Articles

How to use JavaScript variables in jQuery selectors?

Amit D

Amit D

Updated on 19-Dec-2019 06:24:39

571 Views

It’s quite easy to use JavaScript variables in jQuery selectors.ExampleLet’s seen an example to use JavaScript variables in jQuery to hide an element:Live Demo $(document).ready(function(){    $("input").click(function(){         var name = this.name;       $("input[name=" + name + "]").hide();     } ... Read More

How to use jQuery hasAttribute() method to see if there is an attribute on an element?

Amit D

Amit D

Updated on 18-Dec-2019 10:07:36

1K+ Views

Use jQuery hasAttribute() method to see if there is an attribute for an element.ExampleYou can try to run the following code to learn how to use hasAttribute() method:Live Demo                          $(document).ready(function(){           ... Read More

How do I find a certain attribute exists or not for a selected item in jQuery?

Amit D

Amit D

Updated on 18-Dec-2019 08:41:53

80 Views

To find a certain attribute exists or not for a selected item in jQuery, use the hasAttribute() method.ExampleYou can try to run the following code to learn how to find a certain attribute exists or not:Live Demo                     ... Read More

How to use *= operator in jQuery attribute selector?

Amit D

Amit D

Updated on 18-Dec-2019 08:40:36

359 Views

The *= operator is used to filter elements for attribute containing the given value.ExampleYou can try to run the following code to learn how to *= operator to filter attributes on the basis of text:Live Demo $(document).ready(function(){    $( "div[myattr*='subject']" ).css("background-color", "yellow");     }); Java HTML Ruby

How to find an element based on a data-attribute value in jQuery?

Amit D

Amit D

Updated on 18-Dec-2019 08:39:29

371 Views

To find an element based on a data-attribute value using jQuery is quite easy.ExampleYou can try to run the following code to learn how to find an element based on a data-attribute value using jQuery:Live Demo    $(document).ready(function() {       $('[data-slide="2"]').addClass('demo');    }); ... Read More

How to use OR Operation in jQuery Attribute Selectors?

Amit D

Amit D

Updated on 18-Dec-2019 08:38:40

114 Views

Use comma to work with OR operation in jQuery Attribute Selector.ExampleYou can try to run the following code to learn how to use OR operation in jQuery attribute selector:Live Demo                          $(document).ready(function(){         ... Read More

How do we use jQuery Attribute selector with a period?

Amit D

Amit D

Updated on 18-Dec-2019 08:25:45

219 Views

jQuery Attribute selector is used to select elements with the specified attribute and value. You can easily use it with a period (.) or a hash (#).ExampleYou can try to run the following code to learn how to use jQuery selector with a period:Live Demo $(document).ready(function(){ ... Read More

How to remove disabled attribute using jQuery?

Amit D

Amit D

Updated on 18-Dec-2019 08:24:47

11K+ Views

To remove disabled attribute using jQuery, use the removeAttr() method. You need to first remove the property using the prop() method. It will set the underlying Boolean value to false.ExampleYou can try to run the following code to learn how to remove disabled attribute using jQuery:Live Demo ... Read More

How to set “checked” for a checkbox with jQuery?

Amit D

Amit D

Updated on 18-Dec-2019 08:22:59

2K+ Views

Use the checked attribute to set the checkbox with jQuery. Also, the prop() method is used to get the property value.ExampleYou can try to run the following code to learn how to set checked for a checkbox:Live Demo   jQuery Example     b {     ... Read More

How do we use # in jQuery Attribute Selector?

Amit D

Amit D

Updated on 18-Dec-2019 08:21:18

226 Views

To use # in jQuery attribute selector, include # under *= . This will find the attribute with #.ExampleYou can try to run the following code to learn how to use # in jQuery attribute selector:Live Demo     $(document).ready(function()  {        $( "div[myattr*='#']" ).css("background-color", "yellow");     }); Java HTML Ruby

Previous 1 ... 4 5 6 7 8 ... 12 Next
Advertisements