jQuery Articles

Page 29 of 42

Slide up and down of a div animates its content - jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 508 Views

To toggle content, use slideToggle() in JavaScript.ExampleFollowing is the code: −            Document    .firstDiv {       display: none;    }    .txtBox {       display: block;    }    Press Me to toggle the text box                              Enter your name:                        function toogleTheTextBox() {       $('#firstDiv').slideToggle(function () {          $('#txtBox').focus();       });    } 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 −Press the button “Press Me” to toggle the text box.OutputThe output is as follows −

Read More

Display tooltip text while hovering a textbox in jQuery

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

For this, use jQuery(selector).toolTip().ExampleFollowing is the code: −            Document    Write Your Favourite Subject Name:        jQuery(".demoTooltip").toolTip() 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 will hover the mouse inside the text box, you will get your tooltip −Your Favourite Subject may be JavaScript...Displayed in the below screenshot as well −

Read More

How are the times a user presses the button counted in jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 214 Views

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 More

How to make checkboxes impossible to check in jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 293 Views

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 More

How do you remove all the options of a select box and then add one option and select it with jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 784 Views

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 More

How to get value of data attribute and use it in jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 9K+ Views

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 More

Match the style of element while performing paste - jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 156 Views

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 More

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

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

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 More

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

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 904 Views

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

Refresh page after clearing all form fields in jQuery?

AmitDiwan
AmitDiwan
Updated on 11-Mar-2026 2K+ Views

To refresh page, use the location.reload() in JavaScript. The sample JavaScript code is as follows −Example 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 −

Read More
Showing 281–290 of 413 articles
« Prev 1 27 28 29 30 31 42 Next »
Advertisements