FancyBox iframe returns parent.$ as undefined (using WordPress)

前端 未结 9 2829
无人共我
无人共我 2020-12-04 01:58

I\'m trying to close FancyBox from within the iframe, but parent.$ is always undefined. This is my iframe JavaScript:

 

        
9条回答
  •  春和景丽
    2020-12-04 02:24

    It is undefined because WordPress runs jQuery in noConflict mode. Use this instead:

    parent.jQuery.fancybox.close();
    

    noConflict mode means $ does not equal jQuery. You have to explicitly use jQuery to access what you normally can access with $.

提交回复
热议问题