简体   繁体   中英

How to append a counter to div element

need to append a counter few spaces way from the text " list of items".

jsfiddle

<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);

Your code is looking for a p tag with the class .counter . Add this element.

I would suggest using a span rather that a p if you want it to appear inline with your current text...

 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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM