开发者

jQuery (Append)

开发者 https://www.devze.com 2022-12-15 05:02 出处:网络
For instance I have this html code <div class=\"messageContainer\"> <div clas开发者_如何转开发s=\"message\">

For instance I have this html code

<div class="messageContainer">
  <div clas开发者_如何转开发s="message">
  </div>
</div>

---Here

<div class="messageContainer">
  <div class="message">
  </div>
      <here> :)
</div>

Now I need to create a div with some information located in the text ("---Here"). Is there any way how obviously by using jQuery.


You're looking for the after() command:

$("#messageContainer").after("<div>");

Though in your example, this will add it after every messageContainer. You will need to adjust the selector appropriately. So you'd want #messageContainer:first to add it after only the first container, for example.

before() is also available.

0

精彩评论

暂无评论...
验证码 换一张
取 消