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構造を持っています、
<button class="myBtn myBtnCTA signIn" onclick="javascript:;"> <span>Close</span> </button>
テキストを「閉じる」から「保存して閉じる」に変更したい。これを試しまし$(button .myBtn myBtnCTA signIn span).text()たが、うまくいかないようです。なにか提案を??
$(button .myBtn myBtnCTA signIn span).text()
ドットを使用.して複数のクラスを結合し、セレクターも指定しquotesます。
.
quotes
ライブデモ
$('button.myBtn.myBtnCTA.signIn span').text()
$(".myBtn.myBtnCTA.signIn span").text("Hello world!");
このセレクターは非効率的である可能性があることに注意してください。
これはうまくいくはずです
$(".myBtn.myBtnCTA.signIn>span").text("Save & Close");
ワーキングデモ
このコードを試してください
$(".myBtn.myBtnCTA.signIn span").text("text");