Found 10483 Articles for Web Development

jQuery addClass() with Example

AmitDiwan
Updated on 12-Nov-2019 12:48:53

552 Views

The addClass() method in jQuery is used to add one or more class names to the selected elements.ExampleLet us now see an example to implement the jQuery addClass() method −    .demo * {       display: block;       border: 3px dashed red;       padding: 3px;       margin: 25px;    }    .one {       border: 2px solid yellow;    }    $(document).ready(function(){       $("span.test").next().addClass("one");    }); Heading One This is our demo text in div. child grandchild grandchild grandchild ... Read More

jQuery finish() with Example

AmitDiwan
Updated on 12-Nov-2019 12:44:51

202 Views

The finish() method in jQuery is used to stop the currently-running animations. It removes all queued animations and completes all animations for the selected elements.SyntaxThe syntax is as follows −$(selector).finish(queue)Above, the queue parameter is the name of the queue to stop animation.ExampleLet us now see an example to implement the jQuery finish() method −    div {       background:orange;       height:200px;       width:200px;       padding: 5px;    }    $(document).ready(function(){       $("#begin").click(function(){          $("div").animate({height: 450}, 2000);       });   ... Read More

jQuery focusin() with Example

AmitDiwan
Updated on 12-Nov-2019 12:40:28

200 Views

The focusin() method in jQuery occurs when an element gets focus.SyntaxThe syntax is as follows −$(selector).focusin(function)ExampleLet us now see an example to implement the jQuery focusin() method −    .demo {       color: blue;    } $(document).ready(function(){    $("input").focusin(function(){       $("p").html("focusin event triggered");    });    $("input").focusout(function(){       $("p").html("focusout event triggered");    }); }); Student Details Student Name: OutputThis will produce the following output −Now, click inside to get focus −Click outside to lose focus −

jQuery first() with Example

AmitDiwan
Updated on 12-Nov-2019 12:19:29

171 Views

The first() method in jQuery selects the first element from the specified elements.SyntaxThe syntax is as follows −$(selector).first()ExampleLet us now see an example to implement the jQuery first() method −    $(document).ready(function(){       $("p").first().css("color", "blue");    }); Demo Heading This is a line. This is another line. This is line 3. OutputThis will produce the following output −ExampleLet us see another example −    .one {       background-color: orange;       border: 2px dashed red;    }    $(document).ready(function(){   ... Read More

jQuery fadeToggle() Method

AmitDiwan
Updated on 12-Nov-2019 11:59:17

269 Views

The fadeToggle() method in jQuery is used to toggle between the fadeIn() and fadeOut() methods.SyntaxThe syntax is as follows −$(selector).fadeToggle(speed, easing, callback)Above, speed is the speed of the fading effect. The easing can be swing or linear for speed at different animation points. Callback is the function to be executed after the method gets finished.ExampleLet us now see an example to implement the jQuery fadeToggle() method −    $(document).ready(function(){       $(".btnout").click(function(){          $("div").fadeOut();       });       $(".btnin").click(function(){          $("div").fadeIn();       });   ... Read More

jQuery fadeTo() Method

AmitDiwan
Updated on 12-Nov-2019 11:56:44

243 Views

The fadeTo() method in jQuery is used to gradually change the opacity for selected elements to a specified opacity.SyntaxThe syntax is as follows −$(selector).fadeTo(speed, opacity, easing, callback)Above, speed is the speed of the fading effect, whereas opacity specifies the opacity to fade to. The easing can be swing or linear for speed at different animation points. Callback is the function to be executed after the method gets finished.ExampleLet us now see an example to implement the jQuery fadeTo() method −    $(document).ready(function(){       $(".btnout").click(function(){          $("div").fadeOut();       });   ... Read More

jQuery find() with Example

AmitDiwan
Updated on 12-Nov-2019 11:54:18

334 Views

The find() method in jQuery is used to return descendant elements of the selected element.SyntaxThe syntax is as follows −$(selector).find(filter)Above, filter is a selector expression to filter the search for descendants.ExampleLet us now see an example to implement the jQuery find() method −    .demo * {       display: block;       border: 2px solid blue;       padding: 5px;       margin: 15px;    }    $(document).ready(function(){       $("ol").find("span").css({"background-color": "orange", "color": "black","border": "3px dashed orange"});    }); body ol ol ol li span OutputThis will produce the following output −

jQuery fadeOut() with Example

AmitDiwan
Updated on 12-Nov-2019 11:48:20

204 Views

The fadeOut() method in jQuery is used to change the opacity, for selected elements, from visible to hidden.SyntaxThe syntax is as follows −$(selector).fadeOut(speed, easing, callback)Above, speed is the speed of the fading effect. The easing can be swing or linear for speed at different animation points. Callback is the function to be executed after the method gets finished.ExampleLet us now see an example to implement the jQuery fadeOut() method −    $(document).ready(function(){       $(".btnout").click(function(){          $("div").fadeOut();       });       $(".btnin").click(function(){          $("div").fadeIn();     ... Read More

jQuery attr() Method

AmitDiwan
Updated on 12-Nov-2019 11:36:10

296 Views

The attr() method in jQuery is used to set or return attributes and values of the selected elements.SyntaxThe syntax is as follows −$(selector).attr(attribute)ExampleLet us now see an example to implement the jQuery attr() method −    $(document).ready(function(){       $("button").click(function(){          alert("Input Type (Student Id) = " + $("input").attr("type"));       });    }); Student Details Student Id: Click me Click on the button above to return the type of the input. OutputThis will produce the following output −Click on the above button to display the type of the input text −

jQuery appendTo() with Example

AmitDiwan
Updated on 12-Nov-2019 11:25:53

505 Views

The appendTo() method in jQuery is used to insert HTML elements at the end of the selected elements.SyntaxThe syntax is as follows −$(content).appendTo(selector)Above, content is the content to be inserted.ExampleLet us now see an example to implement the jQuery appendTo() method −    $(document).ready(function(){       $("button").click(function(){          $("New").appendTo("h3");       });    }); Blog Posts How to install Java? How to install Ruby? Click me to check new and old post status OutputThis will produce the following output −Now, click on the button above −

Advertisements