-1

When a div has zero height, I try to add a javascript code.

HTML:

<div class="med_rec"></div>

jQuery:

    if ($(".med_rec").height() === 0) {

 $('.med_rec').text('<script type="text/javascript"  src="//static.criteo.net/js/ld/publishertag.js"></script>
<script type="text/javascript">
Criteo.DisplayAd({
"zoneid": 11111,
"async": false});
</script>')    

}

I tried it with

</' + 'script>

but there is always a syntax error.

Thank you

labu77
  • 605
  • 1
  • 9
  • 30

1 Answers1

0

Apparently the problem was with : '<' and '>'

Use this:

$('.med_rec').append('\<script type="text/javascript"  src="//static.criteo.net/js/ld/publishertag.js"\>\</script\><script type="text/javascript">Criteo.DisplayAd({"zoneid": 11111,"async": false});\</script\>');

I hope it helps

Abhay Maurya
  • 11,819
  • 8
  • 46
  • 64