我有以下代码来计算页面内的 div 数量:
jQuery(function($) {
$(document).ready(function() {
alert( $(".contentMachine").length );
});
});
现在,我希望结果出现在我制作的 html div 中:
<span class="subtitleMain" id="totalMachines">0</span>
如何将数字放入其中,而不是每次加载页面时都出现警告框?
抱歉!我昨天才开始学习 javascript。
最佳答案
像这样:
$(document).ready(function() {
$("#totalMachines").text($(".contentMachine").length);
});
关于javascript - 如何在 div 中显示 jquery 警报消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55682721/