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.
アンカー タグを使用しており、jQuery でそのコンテンツにアクセスする必要があります。これから「テキスト」にアクセスする必要があります。$("#AnchorID").attr("href")私は何か他のことを知っていましたが、その値 (「テキスト」) を取得する方法はありますか?
$("#AnchorID").attr("href")
<a href="">text</a>
$("#AnchorID").text() を使用します。
ライブデモ
<a id="AnchorID" href="">text</a>
テキストを取得するには
textOfAnchor = $("#AnchorID").text();
テキストを変更するには
$("#AnchorID").text("new text");
html を取得するには
htmlOfAnchor = $("#AnchorID").html();