divでdivになり、そのdivのテキストを "Sold out"に変更する単純なスクリプトを作成しようとしています。ただし、.text
は「売り切れ」ではなく、[Object, Object]
を返しています。私が間違っていることを誰かが教えてくれれば、とても感謝しています。前もって感謝します。jQuery - .textは、変数の代わりに[Object Object]を返します。
敬具、ジョージ
$(function Store(){
Status = "Sold out";
$("div").each(function(){
$(this).contents().not($(this).children()).text(Status);
alert($(this).contents().not($(this).children()).text(Status));
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="Wallet">
<div class="Price">
10.00$
</div>
<div class="Price">
20.00$
</div>
<div class="Price">
30.00$
</div>
</div>
「売り切れ」という警告を表示したい場合は、それを直接警告するだけではどうですか? – Pytth
@Pytth明らかに、彼の実際の仕事は簡略化されています。そこではテキストは可変です。 – Barmar