Quantcast
Channel: プログラム の個人的なメモ
Viewing all articles
Browse latest Browse all 860

【JS】【jQuery】jQuery 文法編

$
0
0

html

* 該当箇所の中身のテキストを差し替える

サンプル

$("#sample").html("書き換える");

append

* 該当箇所の中身のテキストに追加する

サンプル

$("#sample").append ("この文字列を書き足す");

■パターン1

$("[任意のタグ名]")

* 「ドキュメント内の全てのタグ要素」が対象

サンプル

$("p").html("ドキュメント内の全てのp要素");

■パターン2

$("#[任意の文字列]")

* 「id="[任意の文字列]"の属性」が対象

サンプル

$("#aaa").append("id='aaa'");

■パターン3

$(".[任意の文字列]")

* 「class="[任意の文字列]"の属性」が対象

サンプル

$(".aaa").append("class='aaa'");

■パターン4

$("[任意のタグ名].[任意の文字列]")

* 「class="[任意の文字列]"の属性を持つタグ名」が対象

サンプル

$("h1.aaa").html("class='aaa'のh1要素");

■パターン5

$("[任意のタグ名]#[任意の文字列]")

* 「id="[任意の文字列]"の属性を持つタグ名」が対象

サンプル

$("h2#aaa").html("id='aaa'のh2要素");

■パターン6

$("[任意のタグ名1], [任意のタグ名2], ...")

* 「ドキュメント内の全てのタグ名1, タグ名2」が対象

サンプル

$("h3, h4").html("h3, h4タグが対象");



Viewing all articles
Browse latest Browse all 860

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>