I have this HTML:
<div class="group-sizing">
<div class="form-group">
<div>
<h3>Guest <span>1</span> Welcome</h3>
<div>
<select id="level1"></select>
</div>
</div>
</div>
</div>
I have this function:
var guestBlock = $(".group-sizing").html();
$("#guestNum").change(function(){
var count = $(this).val();
$(".group-sizing .form-group:gt("+(count-1)+")").remove();
for (var i = $(".group-sizing .form-group").length; i < count; i++){
$(guestBlock).find(?????????).html(i); //find and change span and id of select
$(".group-sizing").append(guestBlock); //then print the block
};
});
In $(guestBlock).find() I want to find the span from the <h3> and the id from the <select>. Then increment them by i but so far I haven't been able to get it. It always prints with 1 in those spaces.
?????????is not a valid selector -- so what selectors have you tried?$("#guestNum").change(function(){<select id="guestNum">is a select earlier in the HTML. That calls the change function.<h3>Guest <span>2</span> Welcome</h3>and<select id="level2">and so on according to the for statement.