jQuery div 内の span にテキストを追加する 質問する

jQuery div 内の span にテキストを追加する 質問する
<div id="tagscloud">
       <span></span>
</div>

以下のコードのように、span 内にテキストを追加するにはどうすればよいですか?

<span>**tag cloud**</span>

編集: 実際にはスパンにはIDがあります

<div id="tagscloud"> <span id="WebPartCaptionWPQ2"></span> </div>

ベストアンサー1

以下を使用できます:

$("#tagscloud span").text("Your text here");

同じコードは 2 番目のケースでも機能します。次のコードも使用できます。

$("#tagscloud #WebPartCaptionWPQ2").text("Your text here");

おすすめ記事