我还没有找到正确的答案:
应该在 & 中转义 (&)onclick="..."
吗?(或者就此而言,在每个 HTML 属性中?)
我试过在 jsFiddle 和 W3C 的验证器上运行转义和非转义测试,两者都在工作......
<div onclick="if (1==1 && 2==2) alert('hello there');">Without escape</div>
<div onclick="if (1==1 && 2==2) alert('hello there');">With escape</div>
http://validator.w3.org/#validate_by_input
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><title></title></head><body>
<div onclick="if (1==1 && 2==2) alert('hello there');">Click me</div><br>
<div onclick="if (1==1 && 2==2) alert('hello there');">Click me</div>
</body></html>
谢谢!