Found 730 Articles for JQuery

How to validate a form using jQuery?

Arnab Chakraborty
Updated on 09-Sep-2023 23:26:40

32K+ Views

At first you have to make a html form like. Validation of a form First name: Last name: Email: Now use jQuery validation plugin to validate forms' data in easier way.first, add jQuery library in your file. then add javascript code: $(document).ready(function() {    $("#form").validate(); }); Then to define rules use simple syntax.jQuery(document).ready(function() {    jQuery("#forms).validate({       rules: {          firstname: 'required',          lastname: 'required',          u_email: {             required: true,   ... Read More

How to select ALL children (in any level) from a parent in jQuery?

Kristi Castro
Updated on 20-Jun-2020 07:35:38

1K+ Views

To select all children from a parent in jQuery, use the find() method. You can try to run the following code to select ALL children in any level −ExampleLive Demo        .myclass * {      display: block;      border: 2px solid lightgrey;      color: lightgrey;      padding: 5px;      margin: 15px;    }         $(document).ready(function(){     $('ul').find('*').css({"color": "red", "border": "2px solid green"});   });     div - great-grandparent   ul    li- child - level 1      ul- child - level 2        li- child - level 3        li- child - level 3                  

Why do we use JSON.stringify() method in jQuery?

Kristi Castro
Updated on 20-Jun-2020 07:32:07

551 Views

JSON or JavaScript Object Notation is a lightweight text-based open standard designed for human-readable data interchange. Use the JSON.stringify() method to convert a JavaScript object into a string.You can try to run the following code to learn how to work with JSON.stringify() method −ExampleLive Demo JSON string is created above   var v = { "name":"Amit", "Rank":1, "city":"India"};   var newJSON = JSON.stringify(v);   document.getElementById("test").innerHTML = newJSON;

How to increase the duration of jQuery effects?

Kristi Castro
Updated on 20-Jun-2020 07:31:03

322 Views

To increase the duration of jQuery effects, set the optional speed parameter. The values include, slow, fast, milliseconds, etc. The fast value is used to increase the duration.Let us see an example with fadeIn() jQuery method. The fadeIn( ) method fades in all matched elements by adjusting their opacity and firing an optional callback after completion. Here is the description of all the parameters used by this method −speed − A string representing one of the three predefined speeds ("slow", "def", or "fast") or the number of milliseconds to run the animation (e.g. 1000).callback − This is optional parameter representing ... Read More

How do I use jQuery effects?

Arnab Chakraborty
Updated on 22-Jun-2020 08:19:58

216 Views

For hiding and showing the div, you can use hide and show method.For hiding$('#id1').hide();For showing$('#id1').show();Example showhide                 $(document).ready(function () {          $('#btn1').click(function () {             $('#id1').hide();          });          $('#btn2').click(function () {             $('#id1').show();          });       });        I Am A Simple Paragraph    Hide    Show MethodDescriptionanimate()Runs a custom animation on the selected elementsclearQueue()Removes all remaining queued functions ... Read More

How to adjust the height of iframe based on the loaded content using jQuery?

Kristi Castro
Updated on 20-Jun-2020 07:25:20

2K+ Views

To adjust the height of iframe, use the jQuery height() method. You can try to run the following code to adjust height of iframe dynamically on button click:ExampleLive Demo                 $(document).ready(function(){         $("button").click(function(){           $("iframe").height(300);         });       });             Change Height

How does $('iframe').ready() method work in jQuery?

Kristi Castro
Updated on 20-Jun-2020 07:24:24

3K+ Views

Here’s an example wherein the iframe size is larger than the page. We will scroll to the top of the page whenever the iframe loads using jQuery −ExampleLive Demo               $(document).ready(function(){       $("button").click(function(){         $('iframe').ready(function(){           $(window).scrollTop(0);         });       });    });           Loop through each image

How to loop through all the iframes elements of a page using jQuery?

Kristi Castro
Updated on 20-Jun-2020 07:22:57

1K+ Views

To loop through all the iframes element of a page, use the jQuery each() method. You can try to run the following code to learn how to loop through all iframes. We have created three iframes below −ExampleLive Demo $(document).ready(function(){   $("button").click(function(){     $("iframe").each(function(){       alert($(this).text())       });   }); });   Qries Q/A   Tutorialspoint Free Learning   Send Files   Loop through iFrames

How to insert new row into table at a certain index using jQuery?

Kristi Castro
Updated on 20-Jun-2020 08:09:28

2K+ Views

To insert a new row into table at a certain index, use the jQuery val() and insertBefore() method. You can try to run the following code to learn how to insert new row into table −ExampleLive Demo     jQuery Example       $(document).ready(function(){               $('#index').val($('#myTable tbody tr').length);     $('#btn1').click(function(){       var indx = $('#index').val()-1;       var newRow = $('New row is added at index '+$('#myTable tbody tr').length+'');       newRow.insertBefore($('#myTable tbody tr:nth('+indx+')'));    });   });                   This is row 1                   This is row 2                 Add

How can I set the content of an iframe without src using jQuery?

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

2K+ Views

To set the content of an iframe without src, use the jQuery html() method. You can try to run the following code to learn how to set the content of an iframe without src attribute −ExampleLive Demo      jQuery Selector                  $(document).ready(function() {     var context = $('iframe')[0].contentWindow.document;     var $body = $('body', context);     $body.html('Hello World!');   });        

Advertisements