Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Looks like the target is an HTML DOM object, not a jquery object. I would test to see if the event.target is an instanceof jQuery like so:</p> <pre><code>var target = (event.target instanceof jQuery) ? event.target : jQuery(event.target); </code></pre> <p>This will ensure that the target object is a jQuery object before calling .closest()</p> <p>Edit: changed $ to jQuery in case of using noConflict</p> <p>Edit #2: I changed your entire second method to this:</p> <pre><code>var _body = jQuery("body"); _body.click(function() { // affilate takeover functions if( _body.attr('id').length &amp;&amp; _body.closest('header').length == 0 &amp;&amp; _body.closest('#wrapper &gt; nav').length == 0 &amp;&amp; _body.closest('#leaderboard &gt; div').length == 0 &amp;&amp; _body.closest('#wrapper2').length == 0 &amp;&amp; _body.closest('body &gt; footer').length == 0 &amp;&amp; _body.attr('name') != 'userfile' &amp;&amp; _body.closest('.ui-datepicker-calendar').length == 0 &amp;&amp; _body.closest('.ui-datepicker-prev').length == 0 &amp;&amp; _body.closest('.ui-datepicker-next').length == 0 &amp;&amp; _body.closest('.editor_control_bar').length == 0 &amp;&amp; _body.closest('.ui-autocomplete').length == 0 &amp;&amp; _body.closest('#fancybox-overlay').length == 0 &amp;&amp; _body.closest('#fancybox-wrap').length == 0 &amp;&amp; _body.attr('href') != '#shoutbox' &amp;&amp; !_body.hasClass('ui-button-text') &amp;&amp; _body.closest('.ui-dialog').length == 0) { // variables var affiliate_url = jQuery("input[name=affiliate_url]").val(); window.open(affiliate_url); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload