我有一些ajax和jquery从PHP脚本加载到页面中的表单。
但是,使用PHP生成的onclick=事件出现了一个问题。
该错误仅在单击按钮时触发。
而且我相当肯定页面的原生JS是好的。
我很确定这个php生成的行有一个错误。
<button type="button" class="button" value="Add" onclick="Mail_M_Plex(0,"Add");" name="Action">Add</button>以下是浏览器在加载页面后所看到的内容
<button type="button" class="button" value="Add" onclick="Mail_M_Plex(0," add");"="" name="Action">Add</button>为什么添加=""并将Add改为小写add
这是错误Uncaught SyntaxError: Unexpected token } line 2
我的问题是,当按下按钮时,应该如何调用Mail_M_Plex(0,"add");?
这是完整的PHP打印出来
$Output =
'<tr>'.
'<td><input name="Email" type="Email" id = "0Email" value="" required placeholder="Mark@Smith.com" ></td>'.
'<td><input name="FName" type="text" id = "0FName" value="" required placeholder="Mark"></td>'.
'<td><input name="LName" type="text" id = "0LName" value="" required placeholder="Smith"></td>'.
'<td><button type="button" class="button" value="Add" onclick="Mail_M_Plex(0,"Add");" name="Action">Add</button>'.
'</td>'.
'<td></td>'.
'</tr>';
echo($Output);下面是加载到其中的html,
<tbody id="PartyEmails"> </tbody>发布于 2014-06-24 14:23:44
使用单引号如下:
<button type="button" class="button" value="Add" onclick="Mail_M_Plex(0,'Add');" name="Action">Add</button>发布于 2014-06-24 14:23:22
双引号中有双引号。你可以用单引号代替。
onclick="Mail_M_Plex(0,'Add');"https://stackoverflow.com/questions/24389061
复制相似问题