jQuery的阿贾克斯加载动态内容加载、内容、动态、jQuery

2023-09-10 21:15:01 作者:手心里的余温

我有执行的code .. $ C $以下行C包含2部分的问题。 一个是一个简单的HTML文件必须通过的Ajax调用另一个HTML页面。

I am having the problem with executing the following lines of code..Code contain 2 part. One is a simple HTML file have a call to another Html page through Ajax.

<html>
<head>
<title>
</title>
<script language="javascript" src="jquery-1.7.1.js"></script>
<script language="javascript">
$(document).ready(function(){
$("#btn").click(function(){
$.ajax({
type: 'GET',
url: 'check.html',
cache:false,
success: function callme(html){
document.getElementById('display').innerHTML=html;
}
});
});
});
</script>
</head>
<body>
<form>
<input type="button" id="btn" value="Click"/>
</form>
<div id="display"></div>
</body>

<html>
<head>
<title>
</title>
<script language="javascript" src="jquery-1.7.1.js"></script>
<script language="javascript">
$(document).ready(function(){
$("#btn").click(function(){
$("#btn").hide();
});
});
</script>
</head>
<body>
<input type="button" id="btn" value="Click"/>
</body>
</html>

问题是,当我尝试点击page1.html的按钮,它会毫不掩饰check.html的jQuery的一部分的按钮,但如果我只是运行check.html页面将隐藏按钮immediately.I唐知道问题出在哪里。

problem is that when I try to click the button of page1.html it will not hide the button of the jquery part of check.html but if I simply run the check.html page it will hide the button immediately.I don't know where is the problem.

推荐答案

在加载页面的check.html那么你有两次BTN页面上的ID。

When you load the check.html in your page then you have two times the id btn on the page.

您是否尝试过改变这种状况,看看是否能解决问题?

Have you tried to change that and see if that solves the problem?

 
精彩推荐