addEventListner() in js

<script> window.addEventListener('load', function () { document.getElementById("btn").click(); }) </script> document.addEventListener("click", function(){   document.getElementById("demo").innerHTML = "Hello World"; }); document.addEventListener("mouseover", triggerBtnClick); document.addEventListener("click", someOtherFunction); document.addEventListener("mouseout", someOtherFunction); <script> function triggerBtnClick() { document.getElementById("btn").click(); } </script

0 Comments

Get and Set CSS Classes

addClass() - Adds one or more classes to the selected elements removeClass() - Removes one or more classes from the selected elements toggleClass() - Toggles between adding/removing classes from the selected elements css() -…

0 Comments

Remove Elements/Content jquery

remove() - Removes the selected element (and its child elements) empty() - Removes the child elements from the selected element A. remove() <script> $(document).ready(function(){ $("button").click(function(){ $("#div1").remove(); }); }); </script> </head> <body> <div…

0 Comments

Append, prepend, after & before in jquery

append() - Inserts content at the end of the selected elements prepend() - Inserts content at the beginning of the selected elements after() - Inserts content after the selected elements before() - Inserts content…

0 Comments

Get & Set Content and Attributes

A. Get Attributes $("#btn1").click(function(){ alert("Text: " + $("#test").text()); }); $("#btn2").click(function(){ alert("HTML: " + $("#test").html()); }); $("button").click(function(){ alert($("#w3s").attr("href")); });   B. Set Attributes $("#btn1").click(function(){ $("#test1").text("Hello world!"); }); $("#btn2").click(function(){ $("#test2").html("<b>Hello world!</b>"); }); $("#btn3").click(function(){ $("#test3").val("Dolly…

0 Comments