Home  >  Article  >  Backend Development  >  javascript-How to implement click execution of js function with parameters in php

javascript-How to implement click execution of js function with parameters in php

WBOY
WBOYOriginal
2016-11-30 23:59:55985browse

javascriptphp

<code> echo "             <tr>              <td><button onclick=\"check(".$user['brandname'].")\">".$user['brandname']."</button></td>             </tr>          ";                    这是我的代码,发现点击后没反应,是为什么。。。。。                    js部分                    function check(a){    alert(a);}</code>

Reply content:

String parameters should be enclosed in quotes

<code> echo "
             <tr>
              <td><button onclick=\"check('".$user['brandname']."')\">".$user['brandname']."</button></td>
             </tr>
          ";
</code>
<code> 你这传给js的值不是一个字符串,解决方法同楼上。
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn