对于这段代码,引号的正确语法应该是什么?
<?php
$cod="<div id='id1' onclick='xmlhttpPost(index.php?ajax="'this.id'") class='divazienda'>".$row[0];
?>
我的问题是我不接受这个结果。js的Id
试试这个:
$cod="<div id='"id1'" onclick='"xmlhttpPost('index.php?ajax=' + this.id);'" class='"divazienda'">".$row[0];
转义双引号(对于每个div属性),因为它们在php双引号
当您将带有当前元素id的字符串传递给onclick函数时-字符串部分需要在引号中,变量部分需要在引号之外