Found 10711 Articles for Web Development

What is the jQuery destructive method end()?

David Meador
Updated on 09-Dec-2019 10:00:12

207 Views

The jQuery end() method reverts the most recent destructive operation, changing the set of matched elements to its previous state right before the destructive operation.This is how you can use it,operations.end()ExampleYou can try to run the following code to learn about jQuery destructive method end(),Live Demo           jQuery end() function                              $(document).ready(function(){             $("p").find("span").end().css("border", "4px red solid");          });                              p{             margin:5px;             padding:5px;          }                         Hello World!        

What is the difference between Grep and Filter in jQuery?

David Meador
Updated on 09-Dec-2019 09:58:26

778 Views

The grep() method finds an element and the filter() method returns elements matching a specific criteria.jQuery grep functionExampleThe grep() function is used to find an element of an array. You can try to run the following code to learn how to work with grep(), Live Demo   jQuery grep() function     div {     color: blue;   }   p {     color: red;     margin: 0;   }       var arr1 = [ 1, 7, 4, 8, 6, 1, 9, 5, 3, 7, ... Read More

What does the .end() function do in jQuery?

Amit D
Updated on 09-Dec-2019 10:01:22

120 Views

The end() method reverts the most recent destructive operation, changing the set of matched elements to its previous state right before the destructive operation.ExampleYou can try to run the following code to learn how to work with end function in jQuery:Live Demo           jQuery end() function                              $(document).ready(function(){             $("p").find("span").end().css("border", "2px blue solid");          });                              p{             margin:10px;             padding:10px;          }                         Hello World!        

What is the difference between jQuery.offsetParent( ) and jQuery.parent() methods in jQuery?

Amit D
Updated on 14-Feb-2020 07:28:47

226 Views

jQuery.offsetParent()The offsetParent() method returns a jQuery collection with the positioned parent of the first matched element.This is the first parent of the element that has position (as in relative or absolute). This method only works with visible elements.ExampleYou can try to run the following code to learn how to work with jQuery.offsetParent() in jQuery:Live Demo           jQuery offsetParent() method                              $(document).ready(function() {                         $("div").click(function () {       ... Read More

How to use jQuery.closest() method with class selector?

Amit D
Updated on 09-Dec-2019 10:15:59

4K+ Views

The closest() method begins with the current element and returns only the first ancestors matching the passed expression. This returned jQuery object has zero or one element. Using the class selector is easy and let us see how to use it below.ExampleYou can try to run the following code to learn how to use jQuery.closest() method with class selector:Live Demo .myclass * {     display: block;     border: 2px solid blue;     color: red;     padding: 5px;     margin:10px; }   $(document).ready(function(){     $("span").closest(".one").css({"color": "maroon", "border": "5px solid ... Read More

What is the difference between $.closest() and $.parents() methods in jQuery?

Amit D
Updated on 14-Feb-2020 07:28:01

679 Views

The jQuery closest and parents method is used to set or get the first or all ancestor element, matching the selector. Let's see the difference below:jQuery closest() methodThe closest() method begins with the current element and returns only the first ancestors matching the passed expression. This returned jQuery object has zero or one element.ExampleYou can try to run the following code to learn how to work with jQuery closest method −Live Demo .myclass * {     display: block;     border: 2px solid blue;     color: red;     padding: 5px;     margin:10px; } ... Read More

How to work with jQuery.closest() method in jQuery?

Amit D
Updated on 09-Dec-2019 10:21:04

207 Views

The closest() method begins with the current element and returns only the first ancestors matching the passed expression. This returned jQuery object has zero or one element.ExampleYou can try to run the following code to learn how to work with jQuery closest method:Live Demo .myclass * {     display: block;     border: 2px solid blue;     color: red;     padding: 5px;     margin:10px; }   $(document).ready(function(){     $("span").closest("ol").css({"color": "gray", "border": "3px solid yellow"});   }); body   div     ol - This is the ... Read More

How does jQuery.nextAll() method work in jQuery?

Amit D
Updated on 09-Dec-2019 10:23:22

88 Views

If you want to return all next sibling elements, then use the nextAll() method.ExampleYou can try to run the following code to learn how to use the jQuery.nextAll() method:Live Demo  .mysiblings * {     display: block;     border: 1px solid green;     padding: 2px;     margin: 10px;     color: blue;  }   $(document).ready(function(){     $("li.myclass").nextAll().css({"color": "maroon", "border": "3px solid "});   });   ol       li- This is the sibling of parent ol     li- This is the sibling of parent ol     li- This is the sibling of parent ol with class 'myclass'     li- next sibling     li- next sibling     li- next sibling     li- next sibling    

What does jQuery.children() method do in jQuery?

Amit D
Updated on 09-Dec-2019 10:27:44

97 Views

If you want to return all the direct children of selected elements, then use the jQuery.children() method,ExampleYou can try to run the following code to learn how to work with jQuery.children() method in jQuery,Live Demo .myclass * {     display: block;     border: 2px solid blue;     color: black;     padding: 3px;     margin: 10px; } $(document).ready(function(){     $("ol").children().css({"color": "red", "border": "5px solid red"}); }); body   div     ol       li - This is the child         span              

What does jQuery.andSelf( ) method do in jQuery?

Amit D
Updated on 09-Dec-2019 08:47:18

80 Views

The andSelf( ) method adds the previous selection to the current selection. The method is useful when you have multiple traversals in your script and then adding something that was matched before the last traversal.ExampleYou can try to run the following code to learn how to work with jQuery.andSelf() method:Live Demo           jQuery andSelf() method                          $(document).ready(function(){             $("div").find("p").andSelf().addClass("border");          });                          p, div {             margin:5px;             padding:5px;          }          .border {             border: 2px solid red;          }          .background {             background:yellow;          }                                  First Paragraph          Second Paragraph              

Advertisements