hi i have a images and i want to create a nav li for each image item.. Now i have this code
var bigImages = $('#imagesList li img'); // gets the Big Images
Then i have created a ul with this id
<ul id="thumbsList">
</ul>
Now using a loop i want to add a blank <li> </li>
as equal to the big images in the array..
var rounds = document.getElementById('thumbsList');
for (var i = 0; i < bigImages.length; i++) {
rounds.appendChild('<li> /li>');
}
Now the console displays this error
`Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'
Please tell me where am i doing it wrong.thanks`.
You are doing it wrong. Since you are using plain javascript, I will answer this in same:
for (var i = 0; i < bigImages.length; i++) {
var p = document.createElement("li"); //This is what you want
rounds.appendChild(p);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.