Reputation: 2525
Any idea why this won't work? What I'm trying to do is add some div tags dynamically and then apply them with a slider.
$(function () {
var testarea = $('<div id="testarea" />');
for (var i = 0; i < 3; i++) {
$('<div class="testslider"></div>').appendTo(testarea);
}
$('#somearea').html(testarea.html());
$(".testslider").slider({
value: 100,
min: 0,
max: 500,
step: 100,
slide: function (event, ui) {
}
});
});
html:
<div id="somearea"></div>
If I just add the div tags normally like so then its ok so I'm not too sure how to apply it dynamically.
Upvotes: 1
Views: 2673
Reputation: 28419
May as well just do it in one go anyway
$(function () {
for (var i = 0; i < 3; i++) {
$('<div class="testslider"/>').slider({
value: 100,
min: 0,
max: 500,
step: 100,
slide: function (event, ui) {
}
}).appendTo('#testarea');
}
});
Upvotes: 2