UPDATE: I want to give an updated answer to this question.(更新:我想对这个问题给出一个更新的答案。)
First, let me state if you're attempting to accomplish what I have below, I recommend that you manage events by adding event listeners instead.(首先,让我说明如果您正在尝试完成下面的操作,我建议您通过添加事件侦听器来管理事件。) I highly recommend that you utilize jQuery for your project and use their syntax to manage event listeners over using DOM.(我强烈建议您为项目使用jQuery ,并使用它们的语法来管理使用DOM的事件监听器。)
QUESTION(题)
Okay, I am basically doing this:(好的,我基本上是这样做的:)
document.getElementById("something").innerHTML = "<img src='something' onmouseover='change('ex1')' />";
I don't want double quotes (") where I put the \'. I only want a single quote, so I am trying to not make it put a double when it is used. I am trying to reach this in the final outcome.(我不想要双引号(“)我把它放在''。我只想要一个单引号,所以我试图在使用它时不要把它放一个双。我试图在最后的结果达到这个。)
<img src="something" onmouseover="change('ex1')" />
Escaping isn't working for me.(逃避对我不起作用。)
My marked answer works fine, however, the cleaner (and more professional-looking way, IMO) is loganfsmyth's answer .(我明确的答案很好,然而,更清洁(更专业的方式,IMO)是loganfsmyth的答案 。)
ask by Matthew translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…