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
Web Development Articles
Page 70 of 801
How do I check whether a checkbox is checked in jQuery?
To check whether a checkbox is checked in jQuery, use the concept of toggle(). Following is the code −Example Document Your name is Adam Smith $('#selectName').click(function() { $("#txtName").toggle(this.checked); }); 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 VS Code editor.OutputThis will produce the following output −When you select the check box, the following will be the output −
Read MoreDisplay all the values of an array in p tag on a web page with JavaScript
For this, you can use .data(anyArrayObject). Following is the code −Example Document const arrayValues = [1000000001,"John","Smith",100, 200, 3000] var originalData = d3.select("body").selectAll("p") .data(arrayValues) .enter() .append("p") .text(function(allValuesOfArray){ console.log(allValuesOfArray+" "); return allValuesOfArray; }) 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 VS Code editor.OutputThis will produce the following output −
Read MoreChild node count in JavaScript?
Use children.length to get the count of child node.Example Document List Of Subject Names are as follows: Javascript MySQL MongoDB Java Python var arrayValueOfSubject = document.getElementById('subjectName').parentNode; console.log("The count of child node is="+arrayValueOfSubject.children.length); 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.OutputThis will produce the following output −
Read MoreSet scroll view with intervals in JavaScript
For this, use the concept of scrollTop and scrollHeight.Example Document #scrollDemo { height: 300px; overflow-y: scroll; } #scrollDataFeatures { height: 500px; background-color: skyblue; } See the below Message and Scroll UP var scrollData = document.getElementById("scrollDemo"); scrollData.scrollTop = scrollData.scrollHeight setInterval(() =>{ var heading3Data = document.createElement("h3"); heading3Data.innerHTML = "Scroll Down...Please Scroll UP" scrollData.appendChild(heading3Data); scrollData.scrollTop = ...
Read MoreHow to make my textfield empty after button click in JavaScript?
For this, you can use onclick=”yourFunctionName()”, and −document.getElementById(“”).value=’’Example Document ClearInputText function clearTheTextField(){ console.log("The text box value="+document.getElementById('txtBox').value) document.getElementById('txtBox').value = ''; } 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 VS Code editor.OutputThis will produce the following output −Now enter some value into the text box and click the button ClearInputText.After entering the value, clicking the button.This will produce the following output −
Read MoreDisplay the dropdown’s (select) selected value on console in JavaScript?
Let’s say the following is our dropdown (select) − Javascript MySQL MongoDB Java Following is the code to display the selected value on Console −Example Document Javascript MySQL MongoDB Java function selectedSubjectName() { var subjectIdNode = document.getElementById('subjectName'); var value = subjectIdNode.options[subjectIdNode.selectedIndex].text; console.log("The selected value=" + value); } To run the above program, save the file name “anyName.html(index.html)” and right click on the file. Select the option “Open ...
Read MoreMulti-selection of Checkboxes on button click in jQuery?
For this, use jQuery() with id property. Following is the code −Example Document .changeColor { color: red }; Javascript MySQL MongoDB Python jQuery("#selectDemo").click(function () { jQuery(this).toggleClass("changeColor"); if (jQuery(this).hasClass("changeColor")) { jQuery(".isSelected").prop("checked", true); jQuery(this).val("Want To UnSelect All Values"); } else { ...
Read MoreHow to avoid inserting NULL values to a table with JavaScript?
In order to get rid of null values inserted into a table, you need to check the condition while entering the value.The condition to check NULL must be as follows −while( !( yourVariableName1==null || yourVariableName2==null || yourVariableName3==null…...N){ // yourStatement1 . . N }The above logic will never allow inserting the null values.Now you can use for loop and insert value into the table without NULL. Following is the code −Example Document Demo Of Inserting the value into the table This is demo on the javascript array ...
Read MoreImplement Onclick in JavaScript and allow web browser to go back to previous page?
For reaching the back page on button click, use the concept of −window.history.go(-1)Example Document 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 clicking the button “Click the button to Goto the Previous Page....”, you will reach the previous page as in the below screenshot −
Read MoreHow do I trigger a function when the time reaches a specific time in JavaScript?
For this, extract the time of specific date time and call the function using setTimeout(). The code is as follows −Example Document function timeToAlert() { alert("The time is 9:36 AM"); } var timeIsBeing936 = new Date("08/09/2020 09:36:00 AM").getTime() , currentTime = new Date().getTime() , subtractMilliSecondsValue = timeIsBeing936 - currentTime; setTimeout(timeToAlert, subtractMilliSecondsValue); 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 More