Found 766 Articles for JQuery

jQuery last() with Examples

AmitDiwan
Updated on 30-Dec-2019 08:07:52

119 Views

The last() method in jQuery is used to return the last element of the selected elements.SyntaxThe syntax is as follows −$(selector).last()ExampleLet us now see an example to implement the jQuery last() method − Live Demo    $(document).ready(function(){       $("div p").last().css("color", "orange");    }); Demo Heading This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. OutputThis ... Read More

jQuery keyup() with Examples

AmitDiwan
Updated on 30-Dec-2019 08:04:36

1K+ Views

The keyup() method in jQuery is used to trigger the keyup event. It occurs when the keyboard key is released.SyntaxThe syntax is as follows −$(selector).keyup(func)ExampleLet us now see an example to implement the jQuery keyup() method− Live Demo    $(document).ready(function(){       $("input").keydown(function(){          $("input").css("color", "red");       });       $("input").keyup(function(){          $("input").css("color", "blue");       });    }); Registeration Enter username of the student: Username: OutputThis will produce the following output −Now, when a keyboard key is pressed down (on ... Read More

jQuery keypress() with Examples

AmitDiwan
Updated on 30-Dec-2019 08:01:17

387 Views

The keypress method in jQuery is used to trigger the keypress event. It occurs when a keyboard key is pressed down.SyntaxThe syntax is as follows −$(selector).keypress(func)ExampleLet us now see an example to implement the jQuery keypress() method− Live Demo    count = 0;    $(document).ready(function(){       $("input").keypress(function(){          $("span").text(count += 1);       });       $("input").keyup(function(){          $("input").css("color", "blue");       });    }); Registeration Enter username of the student: Username: Key is pressed 0 times. OutputThis will produce the following output−Now, when the key is pressed, the count of the number of keys appeared−

jQuery mousemove() with Examples

AmitDiwan
Updated on 30-Dec-2019 07:57:30

559 Views

The mousemove() method in jQuery is used to trigger the mousemove event. It occurs whenever the mouse pointer moves within the selected element.SyntaxThe syntax is as follows−$(selector).mousemove(func)ExampleLet us now see an example to implement the jQuery mousemove() method− Live Demo    $(document).ready(function(){       $("h2").mouseenter(function(){          $("h2").css("color", "red");       });       $("h2").mouseleave(function(){          $("h2").css("color", "blue");       });       $("h2").mousemove(function(event){          $("p").text("x = "+event.pageX + ", y = " + event.pageY);       });    }); ... Read More

jQuery mouseleave() with Examples

AmitDiwan
Updated on 30-Dec-2019 07:53:49

278 Views

The mouseleave() method in jQuery is used to trigger the mouseleave event. It occurs when the mouse pointer leaves the selected element.SyntaxThe syntax is as follows −$(selector).mouseleave(func)ExampleLet us now see an example to implement the jQuery mouseleave() method− Live Demo    $(document).ready(function(){       $("h2").mouseenter(function(){          $("h2").css("color", "red");       });       $("h2").mouseleave(function(){          $("h2").css("color", "blue");       });    }); Demo Heading OutputThis will produce the following output−Keep the mouse cursor on the text (mouse enter) and the text color will ... Read More

jQuery mouseenter() with Examples

AmitDiwan
Updated on 30-Dec-2019 07:50:59

269 Views

The mouseenter() method in jQuery is used to trigger the mouseenter event. It occurs when the mouse pointer enters the selected element.SyntaxThe syntax is as follows−$(selector).mouseenter(func)ExampleLet us now see an example to implement the jQuery mouseenter() method− Live Demo    $(document).ready(function(){       $("h2").mouseenter(function(){          $("h2").css("color", "red");       });       $("h2").mouseleave(function(){          $("h2").css("color", "blue");       });    }); Demo Heading OutputThis will produce the following output −Keep the mouse cursor on the text (mouse enter) and the text color will change −

jQuery hasClass() with Examples

AmitDiwan
Updated on 30-Dec-2019 07:48:11

165 Views

The hasClass() method in jQuery is used to check if any of the selected elements is having a specified class name.SyntaxThe syntax is as follows −$(selector).hasClass(classname)Above, the parameter class name is the class name to search for in the selected elements.ExampleLet us now see an example to implement the jQuery hasClass() method− Live Demo    $(document).ready(function(){       $("button").click(function(){          alert($("h2").hasClass("demo"));       });    }); Student Info Teacher Info Click me OutputThis will produce the following output− Click the “Click me” button to display whether any element has class “demo”: 

jQuery has() with Examples

AmitDiwan
Updated on 30-Dec-2019 07:45:27

175 Views

The has() method in jQuery is used to return elements having one or more elements inside them, that matches the specified selector.SyntaxThe syntax is as follows−$(selector).has(ele)Above, the parameter ele is used to specify a selector expression or an element to match elements against.ExampleLet us now see an example to implement the jQuery has() method − Live Demo    $(document).ready(function(){       $("button").click(function(){          $("p").has("span").css("color", "orange");       });    }); h2 {    color: blue; } Student Info This is a demo text. Exam Info This is ... Read More

jQuery resize() with Examples

AmitDiwan
Updated on 30-Dec-2019 07:40:11

348 Views

The resize() method in jQuery is used to trigger the resize event. It occurs when the browser window changes size.SyntaxThe syntax is as follows −$(selector).resize(func)Above, the parameter func is used to specify the function to run when the resize event is triggeredExampleLet us now see an example to implement the jQuery resize() method− Live Demo    var count = 0;    $(document).ready(function(){       $(window).resize(function(){          $("span").text(count += 1);       });    }); span {    padding: 10px;    border: 3px dashed orange;    font-size: 20px; } ... Read More

jQuery Traversing Siblings

AmitDiwan
Updated on 30-Dec-2019 07:36:19

104 Views

With jQuery, you can easily find siblings of an element using the following methods: next(), nextAll(), prev(), prevAll(), siblings(), etc. Let us see some of them traverse siblings−next() methodThe next() method is used to return the next sibling element of the selected element. Let us see an example−Example Live Demo div {    width:600px; } .demo * {    display: block;    border: 2px solid orange;    color: blue;    padding: 10px;    margin: 10px; }    $(document).ready(function(){       $("h3").next().css({"color": "gray", "border": "3px dashed blue"});    }); parent sibling ... Read More

Advertisements