jQuery fadeTo() Method

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

130 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

217 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

125 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 dblclick() with Example

AmitDiwan
Updated on 12-Nov-2019 11:45:00

124 Views

The dblclick() method in jQuery is used to trigger the dblclick event, which occurs when an element is double-clicked.SyntaxThe syntax is as follows −$(selector).dblclick()ExampleLet us now see an example to implement the jQuery dblclick() method −    $(document).ready(function(){       $(document).ready(function() {          $("p").dblclick(function() {             alert('Paragraph double clicked!')          });       });    }); Demo Heading This is a paragraph. Double click here. OutputThis will produce the following output −Double click on the paragraph to generate an alert box −

jQuery closest() with Example

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

228 Views

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

jQuery fadeIn() Method

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

231 Views

The fadeIn() method in jQuery is used to change the opacity, for selected elements, from hidden to visible.SyntaxThe syntax is as follows −$(selector).fadeIn(speed, easing, callback)ExampleAbove, 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.Let us now see an example to implement the jQuery fadeIn() 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

198 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

394 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 −

jQuery event.which property

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

131 Views

The event.which property in jQuery is used to return which keyboard key or mouse button was pressed for the event.SyntaxThe syntax is as follows −event.whichExampleLet us now see an example to implement the jQuery event.which property −    $(document).ready(function(){       $("input").keydown(function(event){          $("div").html("Which key pressed? = " + event.which);       });    }); Student Details Student Name: Student Address: Note: The key pressed in the any of the above input would be visible below. OutputThis will produce the following output −Let us now enter a value and press a key in the input −

jQuery event.type property with Example

AmitDiwan
Updated on 12-Nov-2019 11:22:07

49 Views

The event.type property in jQuery is used to return which event type was triggered.SyntaxThe syntax is as follows −event.typeExampleLet us now see an example to implement the jQuery event.type property −    .demo {       color: blue;       background-color: orange;    }    .test {       color: white;       background-color: black;    }    $(document).ready(function(){       $("p").on("click dblclick mouseover", function(event){          $("div").html(event.type+" event");       });    }); Heading Two Click here and let's see whether it ... Read More

Advertisements