- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 633 Articles for JQuery

Updated on 15-Jul-2020 11:56:25
To add options to a , you need to use append(). Following is the JavaScript code −Example Live Demo
Document
Book
TV
var mySelection = new Option("Mobile", "Samsung Mobile");
$(mySelection).html("Samsung Mobile");
$("#selectCategory").append(mySelection);
To run the above program, save the file name anyName.html(index.html) and right-click on the file and select the option open with live server in VS Code editor.Output 
Updated on 14-Jul-2020 17:17:38
For this, you need to use attr(). The attr() method can be used to either fetch the value of an attribute from the first element in the matched set or set attribute values onto all matched elements.Following is the JavaScript code −Example Live Demo Document $('#myURL').attr('value', 'http://www.facebook.com'); To run the above program, just save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VSCode Editor.OutputLook at the above sample output the URL has been changed ... Read More 
Updated on 24-Feb-2020 11:32:00
Both bootstrap and jquery are used in web development and primarily for the frontend development. As code of bootstrap and jquery majorly executed at client end so also responsible for style and look and feel of the UI.Mostly every application is being developed on two platforms i.e backend and frontend in which backend is developed by high level language such as JAVA, DOT NET etc. while frontend has been developed by client end language such as BOOTSTRAP, JQUERY etc.Following are the important differences between Bootstrap and JQuerySr. No.KeyBootstrapJQuery1DefinitionBootstrap is basically a framework developed by Twitter used for frontend web development ... Read More 
Updated on 31-Dec-2019 09:33:09
The get() method in jQuery is used to get the DOM elements matched by the selector.SyntaxThe syntax is as follows −$(selector).get(index)Above, the index specifies which of the matching elements to get.Let us now see an example to implement the jQuery get() method −Example Live Demo $(document).ready(function(){ $("button").click(function(){ var res = $("li").get(2); $("span").text(res.innerHTML); }); }); Devices TV Laptop Headphone Earphone SSD 3rd li element OutputThis will produce the following output −Now, click on the button −ExampleLet ... Read More 
Updated on 31-Dec-2019 09:29:42
The each() method in jQuery is used to execute a function for each matched element.SyntaxThe syntax is as follows −$(selector).each(function(index, ele))Above, the index is the position of the selector, whereas ele is the current element.Let us now see an example to implement the jQuery each() method −Example Live Demo $(document).ready(function(){ $("button").click(function(){ $("li").each(function(){ alert($(this).text()) }); }); }); Devices TV Laptop Headphone Earphone SSD Get each element OutputThis will produce the ... Read More 
Updated on 31-Dec-2019 09:25:52
The length property in jQuery is used to get the number of elements in the jQuery object.SyntaxThe syntax is as follows −$(selector).lengthExampleLet us now see an example to implement the jQuery length property − Live Demo
$(document).ready(function(){
$("button").click(function(){
document.getElementById("demo").innerHTML = "Count = " + $("li").length
});
});
Devices
TV
Laptop
Headphone
Earphone
SSD
Count of li
OutputThis will produce the following output −Click “Count of li” to get the number of li elements − 
Updated on 31-Dec-2019 09:23:39
To traverse and find ancestors of an element, jQuery has the following methods: parent(), parents() and parentsUntil()−parent() methodThe parent() method in jQuery is used to return the direct parent element of the selected element. Let us see an example −Example Live Demo div { width:600px; } .demo * { display: block; border: 2px solid yellow; color: blue; padding: 10px; margin: 10px; } $(document).ready(function(){ $("span").parent().css({"color": "blue", "border": "3px dashed blue"}); }); great-great-grandparent great-grandparent grandparent parent span OutputThis will produce ... Read More 
Updated on 31-Dec-2019 09:17:59
The select() method in jQuery is used to trigger the select event.syntaxThe syntax is as follows −$(selector).select(func)Above, the func parameter is used to specify the function to run when the select event is triggered. It occurs when a text is selected. The selection should be in a text area or a text field.Let us now see an example to implement the jQuery select() method −Example Live Demo $(document).ready(function(){ $("input").select(function(){ alert("You have selected some text..."); }); }); div { border: 3px dashed orange; ... Read More 
Updated on 31-Dec-2019 09:14:34
The toArray() method in jQuery is used to get all the DOM elements contained in the jQuery set, as an arraySyntaxThe syntax is as follows −$(selector).toArray()Let us now see an example to implement the jQuery toArray() method −Example Live Demo $(document).ready(function(){ $("button").click(function(){ var arr = $("p").toArray() for (var k = 0; i< arr.length; k++) { alert(arr[k].innerHTML); } }); }); Devices This is demo text 1. This is demo text ... Read More 
Updated on 31-Dec-2019 09:11:50
The is() method in jQuery is used to check whether one of the selected elements matches the value in parameter selectorEle.SyntaxThe syntax is as follows −$(selector).is(selectorElement, func(index, element))Above, selectorEle is a selector expression, element or jQuery object to match with the current set of the element. The func parameter is used to specify a function to run for the group of selected elements.ExampleLet us now see an example to implement the jQuery is() method − Live Demo div { width:600px; } .demo * { display: block; border: 2px solid yellow; color: blue; padding: ... Read More Advertisements