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
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
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
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?
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
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
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
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
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 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
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP