javascript - jQuery/Check if image is wrapped in a list item -
this question has answer here:
- jquery check if parent has id 3 answers
i'm using javascript , jquery make light box, , have simple function wraps each image, inside container div, list item, want check see if they're wrapped in list items or not. know of way it?
something this:
$('img, div.lbcontainer').each( function() { //other stuff if ( $(this).parent() = li) { // not sure of syntax $img.unwrap(); } else { $img.wrap('<li id="images_lb"></li>'); } });
you can check parent , length:
if ($(this).parent("li").length) { // parent li } else { // wrap }
Comments
Post a Comment