Add data to each tag with prepend : prepend « jQuery « JavaScript DHTML






Add data to each tag with prepend

   


<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
             $("*", document.body).each(function () {
                  $(this).prepend(document.createTextNode("data"));
                  
             });
        });
    </script>
    <style>
      .y { background:yellow; }
  </style>

  </head>
  <body>
    <body>
       <div><button disabled="disabled">First</button> <span class="selected"></span>
            <span></span>
       </div>

  </body>
</html>

   
    
    
  








Related examples in the same category

1.Prepend content to the inside of every matched element
2.Prepend query
3.Prepends a DOM Element
4.prepend(content): insert elements inside
5.Prepends some HTML to all paragraphs.
6.Prepends a DOM Element to all paragraphs.