Select all <img> that do not have an <a> wrapped around it

22 Views Asked by At

Hello and thank you for your help in advance,

I am using a zoom plugin for jQuery that zooms images when mouse clicks . I want to put my script within skin so that it will work on all images within website. But I have a problem where I am wrapping an a tag around some images (I do not want these to zoom). So I tryed to come up with something that would select just the img without a tags around img.

 $(window).load(function(){
        
  $('img').filter(function(){
      //return !$(this).parents().hasClass('logo');this works but does not help me on other pages
      //return !$(this).parents().contains('a');//this does not work?
      return !$(this).closest('a');//this does not work 

}).wrap('<span style="display:inline-block"></span>')
    .css('display', 'block')
    .parent()
    .zoom({ on:'click' });
    
0

There are 0 best solutions below