Found 633 Articles for JQuery

Manipulate two selects on page load with jQuery

AmitDiwan
Updated on 01-Oct-2020 13:20:39
Let’s say the following is our first select −    John    David    Bob    Mike    Sam    Carol Following is our second select −    David    Mike    Carol We need to remove the options in the first select, which are similar to options in the second select. For this, use val(). Following is the complete code −Example Live Demo              Document           John       David       Bob       Mike       Sam       Carol               David       Mike       Carol        $('#remaining_name > option').each(function (i, el) {       var value = $(el).val();       $('#all_present_name > option[value="' + value + '"]').remove();    }); OutputThe output is as follows −

Fetch value from Alert pop up in jQuery

AmitDiwan
Updated on 11-Sep-2020 06:35:05
To fetch value from alert pop up, use alert(). At first, use prompt() to input the value from user. Following is the code −Example Live Demo Document    var value = prompt("Please enter an integer value");    var multiplyBy10=10*value;    alert("Result after multiplying by 10 = "+ multiplyBy10); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor −OutputThis will produce the following output −Put an integer value and click the OK button.After clicking the OK button, the snapshot is as follows −

List View Search list on typing with filter like keyword search using jQuery?

AmitDiwan
Updated on 10-Sep-2020 07:25:48
Let’s the following is our input type, wherein the user will search −Now, use hide() and show() to display only relevant search and hide rest. For example, on typing “Ja”, related keywords like “Java” and “JavaScript” should be visible because it begins with “Ja”.Example Live Demo Document Enter the keyword.. JavaScript John Smith Java David Miller -1) {             $(this).show();             $(this).prev('.subjectName').last().show();          } else {             $(this).hide();     ... Read More

How to hide table rows containing zero value with jQuery?

AmitDiwan
Updated on 10-Sep-2020 07:22:42
Let’s say the following is our table with product quantity records − qty: qty: qty: qty: Let us now hide using the hide() method. Following is the code −Example Live Demo Document qty: qty: qty: qty:    $('.hideRowContainingZeroValue input').filter(function(){       return +this.value === 0;    }).closest("tr").hide() To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.OutputThis will produce the following output −

Change input type value attribute in jQuery

AmitDiwan
Updated on 10-Sep-2020 07:09:35
Let’s say the following is our input type with value, “John Smith” −To change, use the attr() method −$('#changeTheName').attr('value', 'Please enter your name.......');You need to use the concept of attr(). Following is the code −Example Live Demo Document    $('#changeTheName').attr('value', 'Please enter your name.......'); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.OutputThis will produce the following output −

Place an H1 element and its text at a particular index in jQuery

AmitDiwan
Updated on 10-Sep-2020 06:59:49
To set an element and it’s text, use the text() method in jQuery. With that, use the :nth-child selector to place it at a particular position. Following is the code −Example Live Demo Document JavaScript MySQL MongoDB Java C#    $('h1:nth-child(4)').text("Python"); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.OutputThis will produce the following output −

Refresh page after clearing all form fields in jQuery?

AmitDiwan
Updated on 01-Sep-2020 12:30:34
To refresh page, use the location.reload() in JavaScript. The sample JavaScript code is as follows −Example Live Demo Document UserName: Password: Refresh Page    $('#RefreshPage').click(function() {       location.reload();    }); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.OutputThis will produce the following output −After filling the form, the snapshot is as follows −When you click the button “Refresh Page”, the page will refresh and the following output is visible −

How to get value from the first checkbox which is not hidden in jQuery?

AmitDiwan
Updated on 01-Sep-2020 11:55:11
To get value from the first checkbox, which is not hidden, use the :visible selector. Following is the code −Example Live Demo >Document    .notShown {       display: none; }    var v=$('input:checkbox:checked:visible:first').val();    console.log(v); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.This will produce the following output displaying the visible value “second” in console −

Store and retrieve arrays into and from HTML5 data attributes with jQuery?

AmitDiwan
Updated on 01-Sep-2020 11:51:35
To store and retrieve arrays into and from data attributes, use the data() method in jQuery. Following is the syntax −var anyVariableName= $('#yourIdName).data('yourJavscriptArrayName');Following is the jQuery code −Example Live Demo Document    var value = $('#test').data('details');    alert(value); To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open with Live Server” in VS Code editor.OutputThis will produce the following output −

Difference between JQuery vs Cypress

Debomita Bhattacharjee
Updated on 05-Aug-2020 12:02:23
Cypress can work on JQuery objects and call its methods. Thus Cypress can act upon both Cypress and non- Cypress commands. Cypress is asynchronous in nature. It is handled by resolving promises for every Cypress command. This whole process is taken care of by Cypress internally and wrapped and hidden from the end user.However while dealing with JQuery methods, the promise cannot be resolved internally by Cypress and we need to manually resolve them with the help of the then() method in the code.Let us take the example of text() method which is a non-Cypress command and is based on ... Read More
Previous 1 ... 4 5 6 7 8 ... 64 Next
Advertisements