<html> <head> <title>The jQuery Example</title> <base href="https://www.tutorialspoint.com" /> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { $("#myimg").attr("src", "/jquery/images/jquery.jpg"); }); </script> </head> <body> <div> <img id = "myimg" src = "/images/jquery.jpg" alt = "Sample image" /> </div> </body> </html>
<html> <head> <title>The jQuery Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { var title = $("em").attr("title"); $("#divid").text(title); }); </script> </head> <body> <div> <em title = "Bold and Brave">This is first paragraph.</em> <p id = "myid">This is second paragraph.</p> <div id = "divid"></div> </div> </body> </html>
<html> <head> <title>The Selecter Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { $(".big, #div3").css("background-color", "yellow"); }); </script> </head> <body> <div class = "big" id = "div1"> <p>This is first division of the DOM.</p> </div> <div class = "medium" id = "div2"> <p>This is second division of the DOM.</p> </div> <div class = "small" id = "div3"> <p>This is third division of the DOM</p> </div> </body> </html>
<html> <head> <title>The Selecter Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { /* This would select all the elements */ $("*").css("background-color", "yellow"); }); </script> </head> <body> <div class = "big" id = "div1"> <p>This is first division of the DOM.</p> </div> <div class = "medium" id = "div2"> <p>This is second division of the DOM.</p> </div> <div class = "small" id = "div3"> <p>This is third division of the DOM</p> </div> </body> </html>
<html> <head> <title>The Selecter Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { /* This would select second division only*/ $(".big").css("background-color", "yellow"); }); </script> </head> <body> <div class = "big" id="div1"> <p>This is first division of the DOM.</p> </div> <div class = "medium" id = "div2"> <p>This is second division of the DOM.</p> </div> <div class = "small" id = "div3"> <p>This is third division of the DOM</p> </div> </body> </html>
<html> <head> <title>The Selecter Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { /* This would select second division only*/ $("#div2").css("background-color", "yellow"); }); </script> </head> <body> <div class = "big" id = "div1"> <p>This is first division of the DOM.</p> </div> <div class = "medium" id = "div2"> <p>This is second division of the DOM.</p> </div> <div class = "small" id = "div3"> <p>This is third division of the DOM</p> </div> </body> </html>
<html> <head> <title>The Selecter Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { /* This would select all the divisions */ $("div").css("background-color", "yellow"); }); </script> </head> <body> <div class = "big" id = "div1"> <p>This is first division of the DOM.</p> </div> <div class = "medium" id = "div2"> <p>This is second division of the DOM.</p> </div> <div class = "small" id = "div3"> <p>This is third division of the DOM</p> </div> </body> </html>
<html> <head> <title>The jQuery Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type = "text/javascript" language = "javascript"> $(document).ready(function() { $("p").css("background-color", "yellow"); }); </script> </head> <body> <div> <p class = "myclass">This is a paragraph.</p> <p id = "myid">This is second paragraph.</p> <p>This is third paragraph.</p> </div> </body> </html>
<html> <head> <title>The jQuery Example</title> </head> <body> <div> <p>This is a paragraph.</p> <p>This is second paragraph.</p> <p>This is third paragraph.</p> </div> </body> </html>
<html> <head> <title>The jQuery Example</title> <script type = "text/javascript" src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script> <script type = "text/javascript" src = "/jquery/custom.js"></script> </head> <body> <div id = "mydiv"> Click on this to see a dialogue box. </div> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more