I am using a Facebook tracking pixel on my site. The code snippet provided by Facebook looks like this:
<script>
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','//connect.facebook.net/en_US/fbevents.js');
fbq('init', '289122114623663');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="http://ift.tt/1V6crUw"
/></noscript>
Usually, I put this snippet above the </body> tag and go on my merry way, but in this case, I need to NOT run this script if there is a certain div showing on the page.
I had written a jQuery if statement like this:
if (!$('.partner-bar').is(':visible')) {
$("#facebook-pixel").html("");
};
I was planning to put the entire Facebook snippet within the .html() method, thinking that would output the HTML in a div called #facebook-pixel when those conditions are met. but jQuery seems to not like having the instead of the .html() method.
Is there a better way to go about this?
Aucun commentaire:
Enregistrer un commentaire