The append cmd doesn't close my tags, but why? What do i have to change?
for (var i = 0; i<=4; i++)
$("#wrapper").append('<li id=img'+i+'></li>');
always creates only <li id=img1>
and so on but no </li>
?!
Thanks for your help!
The append cmd doesn't close my tags, but why? What do i have to change?
for (var i = 0; i<=4; i++)
$("#wrapper").append('<li id=img'+i+'></li>');
always creates only <li id=img1>
and so on but no </li>
?!
Thanks for your help!
Your code should be:
for (var i = 0; i<=4; i++)
$("#wrapper").append('<li id="img'+i+'"></li>');
I think you forgot the quotes for the id attribute
The code you provided does seem to add the tags you want.
If I run the exact javascript you provided, viewing generated source using the web developer toolbar in firefox gives me <li id="img2"></li>
and inspecting the element in firebug shows me <li id="img2"/>
.
Both of those are closed and proper xhtml. Though if you aren't using xhtml, the closing tag isn't required anyway.