Reputation: 3498
I have a <ul>
with many <li>
.
My <li>
's have different id's: for example: <li class="image" id=1>....</li>
How can I find now this <li>
with the id=1 ??
I tried this-->
var deleteImage = $("ul").find( ".image" ).attr("id").val(1);
...but it doesnt work. Any idea? THANKS!!!
Upvotes: 1
Views: 17927
Reputation: 5354
ID's should never start with numbers. Change your id's to image1, image2, image3, ... Then use:
$('#image1').functionToExecute();
Upvotes: 5
Reputation: 116
The id tag is supposed to be unique within the HTML document. So, assuming you've constructed the HTML appropriately, you should be able to select the li
tag with just:
$('#1')
Upvotes: 0
Reputation: 1454
This is a basic JQuery/CSS selector:
var deleteImage = $("ul").find( "#1.image" );
Upvotes: 6