【发布时间】:2014-09-08 21:03:13
【问题描述】:
我有这个 JQuery 代码和 JS 代码下方的链接。如果链接在 JS 代码下方似乎不起作用,但如果 JS 代码在链接下方则可以。
如何让它与链接上方的 JS 代码一起工作?我需要这样做,因为我在使用 PHP 包含的文件中有 JS 代码。
<div id="EditPage" class="EditPagePopup">
<iframe id="EditPageFrame" width="100%" height="80%" src=""></iframe>
<a id="JQueryClose">×</a>
</div>
<script>
$("a#EditPageLink").click(function (e) {
alert("f");
e.preventDefault();
$("#EditPageFrame").attr("src", $(this).attr("value"));
$("a").removeClass("active");
$(this).addClass("active");
JQueryPopup('#EditPage');
});
</script>
<a id="`EditPageLink`" href="#" value="editcustomer.php?seq='.$customer["sequence"].'"
【问题讨论】:
-
用
$(document).ready包装 -
把script标签放到body标签外面,放到head标签里。它解决了问题
-
id 属性中的刻度是怎么回事?您可能想删除这些。
标签: javascript jquery