javascript - jQuery/Check if image is wrapped in a list item -


this question has answer here:

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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -