jQuery parents Method
home
Run
screen_rotation
fullscreen
cloud_download
<!DOCTYPE html> <html> <head> <title>jQuery Demo example</title> <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"> </script> <script type="text/javascript"> $(document).ready(function(){ $( "#parentExample" ).on( "click", function(event) { $("p").parents().css("border","1px solid green").map(function(index,element1) { $(element1).append("I am one in parents of p = "+this.tagName); }) }); }); </script> </head> <body> <div style='border:2px solid blue;padding:10px;'> <div style='border:2px solid blue;padding:10px;'> <div style='border:2px solid blue;padding:10px;'> <p style="padding:10px; background: red;"> <span>Demo paragraph ...........click button to run example.......!</span></p> </div> </div> </div> <h4><a href="javascript:void(0);" id="parentExample">Click to run parents() Example </a></h4> </body> </html>
<!DOCTYPE html> <html> <head> <title>jQuery Demo example</title> <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"> </script> <script type="text/javascript"> $(document).ready(function(){ $( "#parentExample" ).on( "click", function(event) { $("p").parents().css("border","1px solid green").map(function(index,element1) { $(element1).append("I am one in parents of p = "+this.tagName); }) }); }); </script> </head> <body> <div style='border:2px solid blue;padding:10px;'> <div style='border:2px solid blue;padding:10px;'> <div style='border:2px solid blue;padding:10px;'> <p style="padding:10px; background: red;"> <span>Demo paragraph ...........click button to run example.......!</span></p> </div> </div> </div> <h4><a href="javascript:void(0);" id="parentExample">Click to run parents() Example </a></h4> </body> </html>
Copyrights@tutorialsplane.com