how to check if fancybox exists on page already

后端 未结 5 1840
猫巷女王i
猫巷女王i 2021-02-09 01:46

I am trying to check if a fancybox has been loaded already. If so then I run an ajax script to put content inside.

If not I open a fancybox iframe and it fetches content

5条回答
  •  不知归路
    2021-02-09 02:42

    This should work without testing for .length

    if ($('div#fancybox-frame:empty'))
    

    However, :empty does check for text nodes. So if you div has a line break, i.e.,

    it might choke. In that case, place the opening and closing tags on the same line.

提交回复
热议问题