1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【jQuery】id値やクラス名が指定してある要素の中にある、特定のタグ要素を取り出す方法

Posted at

#この記事では、要素の中にあるタグ要素を取り出す方法を解説してます

この記事は、下記サンプルのアンカーテキストの文字列を取り出したい場合の解説です。

<div id="sannple-id">
	<a>アンカーテキスト</a>
</div>
<div class="sannple-class">
	<a>アンカーテキスト</a>
</div>

#まずは、id値やクラス名で特定の要素を取り出すとき
変数に代入する場合で例示します。

var $content = $('#sannple-id');
var $content = $('.sannple-class');

#子要素を取り出す時

var $content = $('a[id="sannple-id"]');
var $content = $('a[class="sannple-class"]');
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?