脚本加载脚本广告

script load script ads

本文关键字:脚本 加载      更新时间:2024-05-13

我有代码html-js-css作为

$('.list li:nth-child(4)').after('<li class="new-elem"></li>'); 
li.new-elem {width:336px; height:280px; background:#faa}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<article class="list">
  <li>Thi is list post 01</li>
  <li>Thi is list post 01</li>
  <li>Thi is list post 01</li>
  <li>Thi is list post 01</li>
  <li>Thi is list post 01</li>
</article>

现在如何插入脚本

<script type="text/javascript">document.write("<iframe src='http://www.myadscode.com/ads/banneriframe.php?pchsh=xxxxxxxxxxxxxxxxxxx&t=336x280&cb=" + (Math.floor(Math.random()*99999) + new Date().getTime()) + "' style='width:336px;height:280px;' frameborder='0' scrolling='no'></iframe>");</script>

作为:

$('.list li:nth-child(4)').after('<li class="new-elem"><script type="text/javascript">document.write("<iframe src='http://www.myadscode.com/ads/banneriframe.php?pchsh=xxxxxxxxxxxxxxxxxxx&t=336x280&cb=" + (Math.floor(Math.random()*99999) + new Date().getTime()) + "' style='width:336px;height:280px;' frameborder='0' scrolling='no'></iframe>");</script></li>');

这是错误代码

感谢

 $(function() { 
     var l = $('.list li').length-1;
        $('.list li').eq(l).after('<li class="new-elem">My script ads here</li>');
     });
     <!-- ========= Or ======= -->
      $(function() { 
         $('.list li').eq('4').after('<li class="new-elem">My script ads here</li>');
 });

使用此

 $('.list li').eq('4').after('<li class="new-elem">My script ads here</li>');

添加类似于此的url

$('.list li').eq('4').after("<li class="new-elem"><iframe src='http://www.myadscode.com/ads/banneriframe.php?pchsh=xxxxxxxxxxxxxxxxxxx&t=3‌​36x280&cb=" + (Math.floor(Math.random()*99999) + new Date().getTime()) + "' style='width:336px;height:280px;' frameborder='0' scrolling='no'></iframe></li>");

代替

$('.list li:nth-child(4)').after('<li class="new-elem">My script ads here</li>');