Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はこのhtmlコードを持っています:
<p class="test" data-id=1>Some Value</p> <p class="test" data-id=2>Some Value</p> <p class="test" data-id=3>Some Value</p> <p class="test" data-id=4>Some Value</p>
<p>に基づいて要素を選択するにはどうすればよいdata-idですか?
<p>
data-id
jQuery の場合:
alert($("p[data-id='1']").html());
デモ
jQuery - 属性セレクター