- 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 695 Articles for JQuery

Updated on 09-Nov-2020 11:15:35
Let’s say we have marks records and we need to sum them. The records are displayed in Radio Button −Marks1 75 { if (evnt.checked) { total = total + parseInt(evnt.value); return; } }); secondMark.forEach((evnt) => { if (evnt.checked) { total = total + parseInt(evnt.value); return; } }); ... Read More 
Updated on 09-Nov-2020 10:49:58
To implement this, extract id from attr() and use replace() to replace the id attribute.ExampleFollowing is the code −
Document
$('[id*="-"]').each(function () {
console.log('Previous Id attribute: ' + $(this).attr('id'));
$(this).attr('id', $(this).attr('id').replace('-', '----'));
console.log('Now Id Attribute: ' + $(this).attr('id'));
});
To run the above program, save the file name “anyName.html(index.html)”. Right click on the file and select the option “Open with Live Server” in VS Code editor.OutputThis will produce the following output −Following is the value on console − 
Updated on 09-Nov-2020 10:46:21
For this, use document.getElementById(“”) along with addEventListener().ExampleFollowing is the code − Live Demo Document FirstName: LastName: const formDetails = document.getElementById("details"); formDetails.addEventListener("submit", async (ev) => { ev.preventDefault(); var fName = document.getElementById("firstName").value; var lName = document.getElementById("lastName").value; console.log("First Name=" + ... Read More 
Updated on 09-Nov-2020 10:42:23
Following is how you can validate RadioBoxes with jQuery −ExampleFollowing is the code − Live Demo Document Gender: Male Female isStudent: yes No var nameValues = 'gen;student'.split(';'); $(function () { $("form").on("submit", function (ev) { if (nameValues.filter(val => $(`input[name=${val}]:checked`).length === 0).length > 0) { ... Read More 
Updated on 09-Nov-2020 07:30:18
Let’s say the following is our fixed element div − Fixed The CSS style to fix the above element −.fixedElement { position: fixed; background-color: skyblue; top: 0; left: 0; right: 0; }Following is our element, which will be scrolled − David Miller Now, use the window.scrollTo().ExampleLet us see the complete code − Live Demo Document .fixedElement { position: fixed; background-color: skyblue; top: 0; left: 0; right: ... Read More 
Updated on 09-Nov-2020 07:24:35
Let’s say the following is our file and we need to read this file using jQuery.The name of the file details −ExampleFollowing is the code − Live Demo Document function chooseFile() { dataFromMyFile = document.getElementById("readFileDemo").files[0]; readDataFromFile = new FileReader(); readDataFromFile.onload = () => { data = readDataFromFile.result; console.log("Your File Data is="); console.log(data); }; readDataFromFile.readAsText(dataFromMyFile); } ... Read More 
Updated on 09-Nov-2020 06:58:31
Let’s say the following is our select − Get First Name Get First Name Only To get only the first word, use split() on the basis of space and can select the 0th index value.ExampleFollowing is the code − Live Demo Document Get First Name Get First Name Only function showFirstValue(choosenObject) { var allValues = choosenObject.value.split(" "); var firstValue = allValues[0]; console.log("The first Name=" + firstValue); } ... Read More 
Updated on 09-Nov-2020 06:55:08
For this, call a function on button click.ExampleFollowing is the code − Live Demo
Document
ClickMeToCopyURL
https://www.tutorialspoint.com/index/
function demoForCopyURL(e) {
event.preventDefault();
var rootText = event.target.parentElement.innerText
var btnText = event.target.innerText
var originalURLValue = rootText.substring(btnText.length + 1)
console.log("THE URL IS=" + originalURLValue)
}
To run the above program, save the file name “anyName.html(index.html)”. Right click on the file and select the option “Open with Live Server” in VSCode editor −OutputThis will produce the following output on console −On clicking the button, you will get the following output on console − 
Updated on 09-Nov-2020 06:37:54
To remove the next element in jQuery, use the remove().ExampleFollowing is the code − Live Demo
Document
cancel(X)
Demo
cancel(X)
Demo
cancel(X)
Demo
$(".demo1").click(function () {
$(this).parent().next("hr").remove();
$(this).parent().remove();
return false;
});
To run the above program, save the file name “anyName.html(index.html)”. Right click on the file and select the option “Open with Live Server” in VSCode editor −OutputThis will produce the following output −Whenever you click the cancel(X), the jQuery will remove the element. This will produce the following output − 
Updated on 26-Oct-2020 10:56:01
Yes, we can use jQuery to get values of selected checkboxes using the concept of input. We have to also use the :checked selector.ExampleFollowing is the code − Document Cricket Listening Music Reading NewsPaper Click Me $(document).ready(function () { $("button").click(function () { $('input[name="checkDemo"]:checked').each(function () { console.log(this.value); }); }); }); To run the above program, save the ... Read More Advertisements