[英]How to append a counter to div element
需要在距離文本“項目列表”幾個空格的地方附加一個計數器。
<div class="itemshead" style="margin-top:4px;"><div class="items">List of Items</div></div>
var count = 00;
counter = setInterval(function(){
$("p.countdown").html(count + " seconds ");
count++;
}, 1000);
您的代碼正在尋找類.counter
的p
標記。 添加此元素。
如果您希望它與當前文本內聯顯示,我建議使用span
而不是p
...
var count = 00; counter = setInterval(function(){ $(".countdown").html(count + " seconds remaining!"); count++; }, 1000);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="itemshead" style="margin-top:4px;"><div class="items">List of Items <span class="countdown"></span></div></div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.