編寫HTML時,我有這個代碼的PHP文件中:使用singlequotes的使用JavaScript
<script>
var myString = '{$data10}';
if (myString.charAt(0)) {
document.write('<a target="_blank"
href="https://www.somedomain.com/join?id={$data10}">
<img src="images/join-bim.png" width="300" height="74"
onMouseOut="this.src="images/join-bim.png""
onMouseOver="this.src="images/join-bimB.png"" /></a>');
} else {
document.write('<a target="_blank"
href="https://www.somedomain.com/join?id=111111">
<img src="images/join-bim.png" width="300" height="74"
onMouseOut="this.src="images/join-bim.png""
onMouseOver="this.src="images/join-bimB.png"" /></a>');
}
</script>
我曾嘗試:由於報價沒有嵌套
onMouseOut="this.src="images/join-bim.png""
,但遇到的問題。
正因爲如此,我又試圖:
onMouseOut="this.src='images/join-bim.png'"
但是,單引號不被接受。