![](/img/trans.png)
[英]Dreamweaver extension to beautify PHP/JavaScript/jQuery code
[英]Javascript/Jquery Code will not run in Dreamweaver
我正在嘗試在Dreamweaver中運行下面顯示的代碼。 但是,我無法弄清為什么第7行出現錯誤。Dreamweaver不會告訴您出了什么問題。 請指教。 錯誤位於“ verso:
”。
$(document).ready(function(e) {
$('#btn-left').click(function(e) {
$(".flipbox1").flippy({
color_target: "red",
direction: "left",
duration: "750",
verso: "<form id="signup" action=" <?=$_SERVER['PHP_SELF']; ?>" method="get">
<fieldset>
<legend>Join Our Mailing List</legend>
<label for="email" id="address-label">Email Address
<span id="response">
<? require_once('inc/store-address.php'); if($_GET['submit']){ echo storeAddress(); } ?>
</span>
</label>
<input type="text" name="email" id="email" />
<input type="image" src="i/join.jpg" name="submit" value="Join" class="btn" alt="Join" />
<div id="no-spam">We'll never spam or give this address away</div>
</fieldset>
</form>",
});
});
});
編輯
$(document).ready(function(e) {
$('#btn-left').click(function(e) {
$(".flipbox1").flippy({
color_target: "red",
direction: "left",
duration: "750",
verso: "<form id=\"signup\" action=\"<?=$_SERVER['PHP_SELF']; ?>\" method=\"get\">
<fieldset>
<legend>Join Our Mailing List</legend>
<label for=\"email\" id=\"address-label\">Email Address
<span id=\"response\">
<? require_once('inc/store-address.php'); if($_GET['submit']){ echo storeAddress(); } ?>
</span>
</label>
<input type=\"text\" name=\"email\" id=\"email\" />
<input type=\"image\" src=\"i/join.jpg\" name=\"submit\" value=\"Join\" class=\"btn\" alt=\"Join\" />
<div id=\"no-spam\">We'll never spam or give this address away</div>
</fieldset>
</form> ",
});
});
});
你的問題在這一行
verso: "<form id="signup" action=" <?=$_SERVER['PHP_SELF']; ?>" method="get">
您使用雙引號將反義詞的整個字符串值括起來,但是id =之后的雙引號使javascript認為您正在關閉字符串。
您需要在外部使用雙引號,在內部使用單引號,或者您需要使用反斜杠對雙引號進行轉義。
兩件事情:
1)由於您使用雙引號將您打開,因此您需要在字符串中使用單引號或將開頭的雙引號更改為單引號;
更改
verso: "<form id="signup" action=" <?=$_SERVER['PHP_SELF']; ?>" method="get">
...
</form>",
至
verso: '<form id="signup" action=" <?=$_SERVER['PHP_SELF']; ?>" method="get">
...
</form>',
2)您需要在html字符串的每一行末尾添加一個+
,以告訴JS繼續在字符串的下一行中查找。 即使JS使用;
到結束行,從技術上講,它們不是必需的,這意味着JS將在換行符處結束行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.