簡體   English   中英

用div標簽包裝iframe標簽

[英]Wrap iframe tags with div tags

我有一些HTML,其中包含帖子內容:

<div class="post-content">
  <iframe width="40" other-properties>
     iframe code
  </iframe>
  Other content and other tags
</div>

如何在div中包裝后內容中找到的所有iframe廣告代碼:

<div class="post-content">
  <div class="video">
    <iframe width="40" other-properties>
       iframe code
    </iframe>
    Other content and other tags
  </div>
</div>
$(".post-content iframe").wrap('<div class="video"></div>');

如果您需要在瀏覽器中執行此操作,則可以使用jQuery(請參閱文檔– http://api.jquery.com/wrapinner/ ):

$(".post-content").wrapInner("<div class='video'></div>")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM