Found 730 Articles for JQuery

How to get the children of the $(this) selector in jQuery?

Kristi Castro
Updated on 20-Jun-2020 08:07:11

145 Views

To get the children of the $(this) selector, use the jQuery find() method. You can try to run the following code to get the children of the $(this) selector −ExampleLive Demo   jQuery Example       $(document).ready(function(){     $('#mydiv').click(function(){       alert($(this).find('img:last-child').attr('src'));    });   });   #my_div {    width: 200px;    height: 200px;    background-color: red;   }    

How to center a div on the screen using jQuery?

Kristi Castro
Updated on 20-Jun-2020 08:05:51

704 Views

To center a div on the screen, use the jQuery centering function jQuery.fn.center. You can try to run the following code to learn how to center a div on the screen:ExampleLive Demo               $(document).ready(function(){       jQuery.fn.center = function(parent) {         if (parent) {           parent = this.parent();         } else {           parent = window;         }       this.css({        "position": "absolute",        "top": ((($(parent).height() ... Read More

How to check if a div is visible using jQuery?

Arnab Chakraborty
Updated on 22-Jun-2020 07:58:38

13K+ Views

You can use .is(‘:visible’) selects all elements that are visible.Example divvisible               $(document).ready(function () {          $("button").click(function () {             var dim = $('#div1').is(":visible");             if (dim == false) {                $('#div1').css({ "display": "block", "color": "red" });             }          });       });     Div is visible    Click Here

How to count number of columns in a table with jQuery

Kristi Castro
Updated on 20-Jun-2020 08:04:48

787 Views

To count number of columns in a table with jQuery, use the each() function with attr(). You can try to run the following code to learn how to count column in a table:EaxmpleLive Demo       jQuery Example             $(document).ready(function(){       var num = 0;       $('tr:nth-child(1) td').each(function () {         if ($(this).attr('colspan')) {           num += +$(this).attr('colspan');         } else {         num++;       }     });    alert("Total Columns= "+num); });         -1st column-     -2nd column-     -3rd column-    

How to count number of rows in a table with jQuery?

Arnab Chakraborty
Updated on 21-Jun-2020 17:04:04

1K+ Views

Example Live Demo table        table,th,td {       border:2px solid black;       margin-left:400px;    }    h2 {       margin-left:400px;    }    button {       margin-left:400px;    }            $(document).ready(function () {       $("button").click(function () {          var rowcount = $('table tr').length;          alert("No. Of Rows ::" +rowcount);       });    }); HTML TABLE NAME AGE DD 35 SB 35 AD 5 AA 5 Click Here

How can I tell if table row is in view using jQuery?

Kristi Castro
Updated on 20-Jun-2020 08:03:51

1K+ Views

To check if table row exists or not, use the is() method, with the :visible selector −if($(".row").is(":visible")) {   alert("Visible!"); }You can try to run the following code to learn how to chck if a row exists or not. It even notifies when a new row is created −ExampleLive Demo   jQuery - Add Table Rows     table{    width: 100%;    margin: 25px 0;    border-collapse: collapse;   }   table, th, td{    border: 1px solid #6C220B;   }   table th, table td{    padding: 8px;    text-align: left;   }   ... Read More

How to call a jQuery function after a certain delay?

Kristi Castro
Updated on 20-Jun-2020 08:02:01

6K+ Views

To call a jQuery function after a certain delay, use the siteTimeout() method. Here, jQuery fadeOut() function is called after some seconds.You can try to run the following code to learn how to work with setTimeout() method in jQuery to call a jQuery function after a delay −ExampleLive Demo         $(document).ready(function(){     $("#button1").bind("click",function() {       setTimeout(function() {         $('#list').fadeOut();}, 2000);     });   });                    Voice        Speak      Write         The above content will fade out after 2 seconds

How to make a jQuery function call after “X” seconds?

Kristi Castro
Updated on 20-Jun-2020 13:12:17

4K+ Views

To make a jQuery function call after “X” seconds, use the siteTimeout() method.On button click, set the following and fade out the element. Here, we have also set the milliseconds. This is the delay that would occur before fading an element:$("#button1").bind("click",function() {    setTimeout(function() {       $('#list').fadeOut();}, 4000); });You can try to run the following code to learn how to work with setTimeout() method in jQuery:Example Live Demo               $(document).ready(function(){          $("#button1").bind("click",function() {             setTimeout(function() {                $('#list').fadeOut();}, 4000);             });          });               India       US       UK     The above data will fade out after 4 seconds

How to delete a row from a table using jQuery?

Saleh Alshahrani
Updated on 12-Feb-2025 19:32:34

3K+ Views

In this article, we will learn to delete a row from a table using jQuery. jQuery, a fast and lightweight JavaScript library, Deleting a row from a table dynamically is a common requirement in web development, especially when working with forms or data tables. Deleting a Row Using jQuery The approach involves attaching a click event listener to a delete button (or any element) within the row. When the button is clicked, the corresponding row is removed from the table. Following are the steps for jQuery Script for deleting a row from a table using jQuery− ... Read More

How to add a new list element under a \'ul\' using jQuery?

Alshifa Hasnain
Updated on 15-May-2025 19:38:04

3K+ Views

In this article, we will learn to add a new list element under a "" using jQuery. jQuery is a popular JavaScript library that simplifies HTML manipulation, event handling, and animations. One of its practical applications is dynamically adding elements to a webpage without requiring a full page reload. Why Use jQuery? DOM (Document Object Model) updating using basic JavaScript might become difficult and needs more than one line of code. jQuery has simplified it through easy selectors and functions. Employing jQuery helps us − Select elements efficiently. Handle events seamlessly. ... Read More

Advertisements