<!DOCTYPE html> <html> <head> <title>Wrap A Div</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $(".parent-a-div").wrap(function() { return "<div class='" + $( this ).text() + "'></div>"; }); $(".p-a-div").wrap("<div class='p-div-div'></div>"); $(".p-a-div").append(" <span>Appended text</span>."); }); </script> <style type="text/css"> .parent-a-div{background-color: red;} .p-a-div{background-color: green;} </style> </head> <body> <div class="body"> <p class="parent-a-div">This is a paragraph.</p> <p class="p-a-div">This is another paragraph.</p> </div> </body> </html>
Categories: Php Mysql Ajax Jquery JavaScript Mysql
0 Comments