Wrap tag created by document.createElement : wrap « jQuery « JavaScript Tutorial






<html>
  <head>
    <script type='text/javascript' src='js/jquery-1.3.2.js'></script>
    <script type='text/javascript'>
$(document).ready(
  function() {
    $('p').wrapAll(document.createElement('div'));
  }
);
    </script>
    <style type='text/css'>

h4, p {
    margin: 5px;  
}
div {
    background: #70d6f0;
    border: 3px solid #7ac3d5;
    margin: 3px;
}
    </style>
  </head>
  <body>

    <p>
asdf
    </p>
  </body>
</html>








30.117.wrap
30.117.1.Wrap to create and add a border
30.117.2.Wrap another tag
30.117.3.wrap(html): injecting additional structure into a document
30.117.4.Wrap a new b around all of the paragraphs.
30.117.5.wrap(elem): Wrap each matched element with the specified element.
30.117.6.Wrap p with div tag
30.117.7.Wrap tag created by document.createElement