HTML Elements, Attributes, and Positions on jQuery

jQuery Apps

Recently I went into studying the jQuery scripts and I believe that these codes can be a start for anyone interested. Following are some order selectors and examples of their use with elements in the preceding code:


radio: –  Selects all elements with the type attribute set to radio. The following code returns the value 1 in an alert box:

alert( $(‘:radio’).length);

checkbox: – Selects all elements with type attribute set to radio. The following code sets the checked attribute to true for all check boxes:

$(‘:checkbox’).attr({checked:’true’});

[attribute]:  – Selects all elements with a specific attribute. The following code displays the number of <img> elements with a height attribute:

alert( $(‘img[height]’).length);

[attribute=value]:  – Selects all elements with a particular attribute set to a specific value. The following code displays the number of elements with a class attribute set to myclass:

alert( $(‘[class=myclass]’).length);

[attribute!=value]: –  Selects all elements with a particular attribute not set to a specific value. The following code displays the number of elements with a class attribute that isn’t myclass. Elements with no class attribute are ignored:

alert( $(‘[class!=myclass]’).length);

 

Permanent link to this article: https://www.xenno.org/1022/html-elements-attributes-and-positions-on-jquery/

6 comments

Skip to comment form

  1. Replik Chopard

  2. Machine translation failed. retry

  3. UGG Boots Овчина манжеты 3166 Дешевые На День благодарения для женщин

  4. Machine translation failed. retry

  5. High-End Швейцарский Rolex реплики швейцарских люкс – Rolex -лучший подделки Rolex часы

  6. Machine translation failed. retry

Leave a Reply

Your email address will not be published.

CAPTCHA *

This site uses Akismet to reduce spam. Learn how your comment data is processed.