What is a good way to write this script more dynamic:
I have a variable which can have a value up to 18.
If $count is 1 I want to remove everything up to 18.
If $count is 2 I want to remove everything up to 18.
And so on.
if($count == 1) {
$('#input-1').remove();
// remove up to 18
}
if($count == 2) {
$('#input-2').remove();
// remove up to 18
}
if($count == 3) {
$('#input-3').remove();
// remove up to 18
}
...
if($count == 18) {
$('#input-18').remove();
}
I did this:
for(var i = 0; i < 18; i++) {
if($count== i) {
$('#input-'+i).remove();
}
}
but it does not remove the divs from i to 18
EDIT: (to be clear)
I want to check each, like $count == i then I want to remove from i to 18
for (var i = $count; i <= 18; i++) { ... }HTMLtoo?