私の画像にimgタグが含まれています。それはクラス「画像」を持つdivの内部です。そのdivの中には、「キャプション」のクラスを持つ別のdivがあります。その "キャプション" divには段落が含まれています。JavaScriptまたはjQueryを使用してコンテンツを自動削除する方法
「キャプション」divの段落を削除し、javascriptまたはjQueryを使用して「キャプション」div自体を削除するにはどうすればよいですか?また
/* Script to delete the paragraph and caption div. */
$(".image img").each(function() {
var $this = $(this),
getClass = $this.attr('img')
splitClass = $this.prop('id').split("-")
if (splitClass[1] <= 20) {
$this.attr("src", "http://lorempicsum.com/futurama/350/200/1");
} else if (splitClass[1] >= 40) {
$this.attr("src", "http://www.top13.net/wp-content/uploads/2014/11/4-small-flowers.jpg");
} else {
$this.attr("src", "http://www.top13.net/wp-content/uploads/2014/11/4-small-flowers.jpg");
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="image">
\t <img id="img-1" src="http://www.top13.net/wp-content/uploads/2014/11/4-small-flowers.jpg" />
\t <div class="caption">
\t \t <p>DELETE THIS TEXT!</p>
\t </div>
</div>
<div class="image">
\t <img id="img-2" src="http://www.top13.net/wp-content/uploads/2014/11/4-small-flowers.jpg" />
\t <div class="caption">
\t \t <p>DELETE THIS TEXT!</p>
\t </div>
</div>
、どのように私はjQueryのオフラインで使用できますか?私はそれをダウンロードする必要がありますか?それ、どうやったら出来るの?
ありがとうございます。
document.querySelector( 'キャプションは、')(削除) – Federico
https://jquery.com/download/ – Federico
@Federicoどこに置いたのですか? –