Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by AmitDiwan
Page 616 of 840
How are the times a user presses the button counted in jQuery?
To count how many times a user presses the button, you need to set counter on button click.ExampleFollowing is the code − Document Press Me The current Value is= 0 var increment = 0; var current = document.getElementById('incrementThisValue'); document.getElementById('pressButton').onclick = (event) => { current.textContent = ++increment; }; 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.OutputThe output is as follows −When you press the button you will get an incremental value which starts from 0,1,2,...NOutputThe output is as follows −
Read MoreHow to make checkboxes impossible to check in jQuery?
To make checkboxes impossible to check, set disabled property to true −JavaScriptFollowing is the code −ExampleFollowing is the code − Document List Of Subject names MySQL JavaScript MongoDB 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.OutputThe output is as follows −You cannot check the checkbox value above since we have disabled it.
Read MoreHow to hide table rows containing zero value with jQuery?
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 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 −
Read MoreList View Search list on typing with filter like keyword search using jQuery?
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 Document Enter the keyword.. JavaScript John Smith Java David Miller -1) { $(this).show(); $(this).prev('.subjectName').last().show(); } else { $(this).hide(); ...
Read MoreHow do you remove all the options of a select box and then add one option and select it with jQuery?
To remove, use remove() and append() to add option in already created select list. Let’s say the following is our select − JavaScript MySQL ExampleFollowing is the code to remove all the options and add a new one − Document JavaScript MySQL $('#demo') .find('option') .remove() .end() .append('MongoDB') .val('MongoDB') ; 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.OutputThe output is as follows −
Read MoreFetch value from Alert pop up in jQuery
To fetch value from alert pop up, use alert(). At first, use prompt() to input the value from user. Following is the code −Example 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 −
Read MoreHow to get value of data attribute and use it in jQuery?
To get value of data attribute, use −$(“yourSelector”).data()The following is our input type with data attribute −ExampleFollowing is the code − Document var value = $('#txtValue').data('value'); console.log("The value is=" + value); OutputThe output is as follows −
Read MoreMatch the style of element while performing paste - jQuery?
For this, use tag. Set it to contenteditable −We have set the following style for paste − pre { min-height: 150px; min-width: 300px; font-family: 'Times New Roman', Times, serif; white-space: pre; background-color: rgb(19, 22, 27); color: #98d8e7; } Now, you can use paste event listener −var getTheData = document.getElementById('data'); getTheData.addEventListener('paste', PutTheDataOnEditor);ExampleFollowing is the code − Document pre { min-height: 150px; min-width: 300px; font-family: 'Times ...
Read MoreStore and retrieve arrays into and from HTML5 data attributes with jQuery?
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 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 −
Read MoreHow to get value from the first checkbox which is not hidden in jQuery?
To get value from the first checkbox, which is not hidden, use the :visible selector. Following is the code −Example >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 −
Read More