Get Substring of a String in jQuery

Amit D
Updated on 09-Dec-2019 08:52:02

6K+ Views

To get substring of a string in jQuery, use the substring() method. It has the following two parameters:from: The from parameter specifies the index where to start the substring.to: The to parameter is optional. It specifies the index where to stop the extraction. This is an optional parameter, which extracts the remaining string, when nothing is mentioned.ExampleYou can try to run the following code to learn how to get substring of a string in jQuery:Live Demo           jQuery subtring                             ... Read More

jQuery andSelf Method Explained

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

175 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              

Get Objects by ID, Class, Tag and Attribute in jQuery

Amit D
Updated on 09-Dec-2019 08:04:36

991 Views

Here’s how you can get objects by ID Selector (#id), by Class Selector (.class), by Tag, and Attribute (.attr()).Get Object by Class SelectorExampleThe element class selector selects all the elements which match with the given class of the elements.Live Demo           jQuery Selector                          $(document).ready(function() {                 $(".big").css("background-color", "yellow");          });                                  This is first ... Read More

Fetch nth DIV from HTML Page using jQuery

Ricky Barnes
Updated on 09-Dec-2019 07:59:33

295 Views

To fetch the nth div from an HTML page, use the jQuery eq() method. It is used to access the index of an element in jQuery. The eq() method refers the position of the element.ExampleYou can try to run the following code to learn how to fetch nth div from an HTML page using jQuery. Here, we will fetch the 2nd div:Live Demo $(document).ready(function(){   $("#button1").click(function(){     alert($("div:eq(1)").text());   }); }); Paragraph One Paragraph Two - 2nd div selected Paragraph Three Which div?

Access Index of an Element in jQuery

Ricky Barnes
Updated on 09-Dec-2019 07:58:09

905 Views

To access the index of an element in jQuery, use the eq() method. The eq() method refers the position of the element.ExampleYou can try to run the following code to learn how to access index of an element in jQuery,Live Demo $(document).ready(function(){    $('ul li').eq(2).css({'background-color':'#E6B16A'});});   India   US   UK   Australia

Access Element with nth Index in jQuery

Ricky Barnes
Updated on 09-Dec-2019 07:50:04

1K+ Views

To access element with nth index from an HTML page, use the jQuery eq() method. It is used to access the index of an element in jQuery. The eq() method refers the position of the element.ExampleYou can try to run the following code to access element with nth index in jQuery. Here, element with 2nd index is considered:Live Demo $(document).ready(function(){    $('ul li').eq(2).css({'background-color':'#E6B16A'});});   India   US   UK   Australia

Difference Between Filter and Find in jQuery

Amit D
Updated on 09-Dec-2019 07:40:19

391 Views

jQuery filter() methodThe jQuery filter() method will return elements matching a specific criteria.ExampleYou can try to run the following code to learn how to work with jQuery.filter() method, Live Demo   $(document).ready(function(){     $("p").filter(".myclass").css("background-color", "gray");   }); Tutorialspoint Free Text Tutorials Free Video Tutorials Connecting Tutors jQuery find() methodThe jQuery.find() method will return the descendant elements of the selected element.ExampleYou can try to run the following code to learn how to work with jQuery.find() method, Live Demo  .myclass * {     display: block;   ... Read More

Locate Descendant Elements of a Specific Type

David Meador
Updated on 09-Dec-2019 07:17:53

157 Views

The find( selector ) method can be used to locate all the descendant elements of a particular type of elements. The selector can be written using any selector syntax.ExampleYou can try to run the following code to learn how to locate all the descendant elements of a particular type of elements:Live Demo           jQuery Example                              $(document).ready(function() {             $("p").find("span").addClass("selected");          });                              .selected {            color:blue;          }                         This is first paragraph and THIS IS BLUE       This is second paragraph and THIS IS ALSO BLUE        

Get Unique Immediate Children of Matched Elements

David Meador
Updated on 09-Dec-2019 07:06:08

128 Views

The children( [selector] ) method gets a set of elements containing all of the unique immediate children of each of the matched set of elements.ExampleYou can try to run the following code to learn how to get a set of elements containing all of the unique immediate children of each of the matched set of elements:Live Demo           jQuery Example                              $(document).ready(function(){             $("div").children(".selected").addClass("blue");          });           ... Read More

Importing, Exporting and Changing Keywords in ABAP

Krantik Chavan
Updated on 09-Dec-2019 06:49:36

5K+ Views

IMPORTING transfers a value from the caller to the called method by passing an actual parameterEXPORTING is just opposite to what IMPORTING does. IT passes value from the method to Caller.CHANGING is transferring the value from caller to method by a variable which is processed or changed and the changed value is passed back to the Caller. Thus it combines both IMPORTING and EXPORTING function.There are a couple of ways in which CHANGING can be used:CHANGING myvar or CHANGING VALUE(myvar)By using, CHANGING myvar , the value of a variable is changed and passed back to the caller or main program.Using ... Read More

Advertisements