is there any way to find it? for example:
var number=5;
$("#"+>number).remove();
but I dont know how do something like it and if is it posibble :) thanks
is there any way to find it? for example:
var number=5;
$("#"+>number).remove();
but I dont know how do something like it and if is it posibble :) thanks
$('div').filter(function() {
return parseInt( this.id, 10) > 5;
}).remove();
If id
contains only number
.
id
.For example:
<div id="myid-5"></div>
<div id="myid-6"></div>
And modify above code as:
$('div').filter(function() {
return parseInt( this.id.replace('myid-',''), 10) > 5;
}).remove();
You can do it with help of the slice
function
Reduce the set of matched elements to a subset specified by a range of indices.
See http://api.jquery.com/slice/
This approach will help you get rid of the numerical indices
See my example on jsfiddle