locateganesh locateganesh - 1 year ago 80
HTML Question

Append elements on value

I'm using roundSlider for radial slider. Which gives me value on slide.
on slide I'm appeding


So what I want exactly is
should as per plates number. If there are 22 plates so
should be only 22 and if plates are 10 then
should also be 10 or vice-versa.

Find Fiddle Demo

Currently, It's just appending in 1 length. I want it to append (add and remove) as per
var tp

var tp = $('.rs-tooltip').text() / 1000;
$('#plates span').text(tp);

Answer Source

Demo Fiddle Here

add with for loop event .The for loop will append the span depend on span value. Initially remove inner content of .mbox .Then its will re added with a help of for loop

function traceEvent(e) {
        var tp = $('.rs-tooltip').text() / 1000;
      $('#plates span').text(tp);
    for(var i=0; i<tp; i++){
        $('.mbox').append('<span id="'+[i]+'"></span>')//add
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download