<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() { var content = $("p#pid1").text(); $("#pid2").html(content); }); </script> <style> .red { color:red; } .green { color:green; } </style> </head> <body> <p class = "green" id = "pid1">This is <i>first paragraph</i>.</p> <p class = "red" id = "pid2">This is second paragraph.</p> </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() { var content = $("p").html(); $("#pid2").html( content ); }); </script> <style> .red { color:red; } .green { color:green; } </style> </head> <body> <p class = "green" id = "pid1">This is first paragraph.</p> <p class = "red" id = "pid2">This is second paragraph.</p> </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() { $("p#pid").click(function () { $(this).toggleClass("red"); }); }); </script> <style> .red { color:red; } </style> </head> <body> <p class = "green">Click following line to see the result</p> <p class = "red" id = "pid">This is first paragraph.</p> </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() { $("p#pid1").removeClass("red"); }); </script> <style> .red { color:red; } .green { color:green; } </style> </head> <body> <p class = "red" id = "pid1">This is first paragraph.</p> <p class = "green" id = "pid2">This is second paragraph.</p> </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() { var content = $("p").html(); $("#pid2").html( content ); }); </script> <style> .red { color:red; } .green { color:green; } </style> </head> <body> <p class = "green" id = "pid1">This is first paragraph.</p> <p class = "red" id = "pid2">This is second paragraph.</p> </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() { $("#result1").text( $("p#pid1").hasClass("red") ); $("#result2").text( $("p#pid2").hasClass("red") ); }); </script> <style> .red { color:red; } .green { color:green; } </style> </head> <body> <p class = "red" id = "pid1">This is first paragraph.</p> <p class = "green" id = "pid2">This is second paragraph.</p> <div id = "result1"></div> <div id = "result2"></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() { $("table").removeAttr("border"); }); </script> </head> <body> <table border = "2"> <tr><td>This is first table</td></tr> </table> <table border = "3"> <tr><td>This is second table</td></tr> </table> <table border = "4"> <tr><td>This is third table</td></tr> </table> </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() { $("table").attr("border", function(index) { return "4px"; }) }); </script> </head> <body> <table> <tr><td>This is first table</td></tr> </table> <table> <tr><td>This is second table</td></tr> </table> <table> <tr><td>This is third table</td></tr> </table> </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() { $("img").attr({ src: "/images/jquery.jpg", title: "jQuery", alt: "jQuery Logo" }); }); </script> </head> <body> <div class = "division" id="divid"> <p>Following is the logo of jQuery</p> <img src = "/jquery/images/jquery-mini-logo.jpg" title = "None" alt = "None" /> </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() { $("em").addClass("selected"); $("#myid").addClass("highlight"); }); </script> <style> .selected { color:red; } .highlight { background:yellow; } </style> </head> <body> <em title = "Bold and Brave">This is first paragraph.</em> <p id = "myid">This is second paragraph.</p> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more