Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <body>
- <p class = 'myp'>this is my p</p>
- </body>
- $(function(){
- $('p.myp').after('<div class = "firstDiv">first div added with jquery</div>');
- $('p.myp').after('<div class = "secondDiv">second div added with jquery</div>');
- console.log($('p.myp').next('div.firstDiv').text());
- console.log($('p.myp').next('div.secondDiv').text());
- });
- <body>
- <p class="myp">this is my p</p>
- <div class="secondDiv">second div added with jquery</div> <!-- this is next -->
- <div class="firstDiv">first div added with jquery</div> <!-- this is not -->
- </body>
- $(function () {
- var first = $('<div />', {
- 'class' : 'firstDiv',
- text : 'first div added with jquery'
- });
- var second = $('<div />', {
- 'class' : 'secondDiv',
- text : 'second div added with jquery'
- });
- $('p.myp').after(first);
- $('p.myp').after(second);
- console.log(first.text());
- console.log(second.text());
- });
- <p class="myp">this is my p</p>
- $('p.myp').after('<div class="firstDiv"></div>');
- <p class="myp">this is my p</p>
- <div class="firstDiv"></div>
- $('p.myp').after('<div class="secondDiv"></div>');
- <p class="myp">this is my p</p>
- <div class="secondDiv"></div>
- <div class="firstDiv"></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement