Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <body>
  2. <p class = 'myp'>this is my p</p>
  3. </body>
  4.  
  5. $(function(){
  6. $('p.myp').after('<div class = "firstDiv">first div added with jquery</div>');
  7. $('p.myp').after('<div class = "secondDiv">second div added with jquery</div>');
  8. console.log($('p.myp').next('div.firstDiv').text());
  9.  
  10. console.log($('p.myp').next('div.secondDiv').text());
  11. });
  12.  
  13. <body>
  14. <p class="myp">this is my p</p>
  15. <div class="secondDiv">second div added with jquery</div> <!-- this is next -->
  16. <div class="firstDiv">first div added with jquery</div> <!-- this is not -->
  17. </body>
  18.  
  19. $(function () {
  20. var first = $('<div />', {
  21. 'class' : 'firstDiv',
  22. text : 'first div added with jquery'
  23. });
  24. var second = $('<div />', {
  25. 'class' : 'secondDiv',
  26. text : 'second div added with jquery'
  27. });
  28.  
  29. $('p.myp').after(first);
  30. $('p.myp').after(second);
  31.  
  32. console.log(first.text());
  33. console.log(second.text());
  34. });
  35.  
  36. <p class="myp">this is my p</p>
  37.  
  38. $('p.myp').after('<div class="firstDiv"></div>');
  39.  
  40. <p class="myp">this is my p</p>
  41. <div class="firstDiv"></div>
  42.  
  43. $('p.myp').after('<div class="secondDiv"></div>');
  44.  
  45. <p class="myp">this is my p</p>
  46. <div class="secondDiv"></div>
  47. <div class="firstDiv"></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement