在php中打印javascript代码无法正常工作

时间:2013-10-29 07:07:56

标签: javascript php html

我想在php echo中添加这个javascript

<a href="#" onClick="document.getElementById('footerSlideContainer').style.display ='block'">ddddddd</a>

我试过这个但没有工作

 echo "  
  <a  href=\"javascript://\" onClick=\"clearChildren(document.getElementById('row11'));\" > <img src='Dealer/images/email_send.png'   style='width:22px;height:22px' />
  Contact Advertiser </a>" ;

1 个答案:

答案 0 :(得分:0)

<?php echo "<a  href=\"javascript://\" onClick=\"document.getElementById('footerSlideContainer').style.display ='block'\" > <img src='Dealer/images/email_send.png'   style='width:22px;height:22px' /> Contact Advertiser </a>"; ?>

试试这段代码。问题是你在onClick事件中的javascript代码。你想做什么?

document.getElementById('footerSlideContainer').style.display ='block'; 

clearChildren(document.getElementById('row11'));

如果你想要第一个复制我的代码,那么你的代码没有任何问题。这意味着clearChildren()上的错误,检查clearChildren()是否定义并且工作正常。