変更スパンテキストjquery
3802 ワード
TL博士概要
jQueryでスパンテキストを変更するのはとても簡単です.
(このようにHTMLを持っていると仮定しましょう).
<span id="one">first text</span><br />
<span id="two">second text</span><br />
<span id="three">third text</span>
1 )単一の要素をidで変更する// change by ID
$('#two').text('jQuery text');
// change by index
$('span').eq(1).text('jQuery text');
ここではすべての要素は$('span')
で選択されますが、この.eq(1)
のようにインデックスを選択できます.
2 )すべての要素を変更する-同じテキスト
$('span').text('jQuery text');
結果は次のようになります.
3 )すべての要素を変更する-異なるテキスト
$('span').each((index, element) => {
$(element).text(`jQuery text - ${index}`);
});
以下のようになります.
そしてそれです.
これでjQueryでスパンテキストを変更する方法を知っています.
そして、あなたが現実のcyber botを取得したい場合は、リンクをクリックします.
次回まで
意志
上級ソフトウェア開発者
Reference
この問題について(変更スパンテキストjquery), 我々は、より多くの情報をここで見つけました https://dev.to/cyberbotmachines/change-span-text-jquery-3c0mテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol