87,909
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>image</title>
<script src="../js/jquery-1.9.1.min.js"></script>
<script src="../js/jquery-ui.min.js"></script>
<script src="../js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var h=document.getElementById("hide");
var p=document.getElementById("pic");
h.click(function(){
p.hide();
});
});
</script>
</head>
<body>
<input type="image" src="load_t.gif" id="pic"/>
<button id="hide" type="button">隐藏</button>
</body>
</html>
$(document).ready(function(){
var h=document.getElementById("hide");
var p=document.getElementById("pic");
//p和h这里是js原生的对象,而下面使用的click和hide是jQuery的方法,是不能混用的。
h.click(function(){
p.hide();
});
//如果你只是想要取id的话,jQuery的方法更简单。
/*
$("#hide").click({
$("#pic").hide();
});
//这里只是使用的jQuery。
*/
//如果使用JS原生的方法,就是:
/*
var h=document.getElementById("hide");
var p=document.getElementById("pic");
h.onclick = function(){
p.style.display = "none";
}
*/
//如果按照你上面的混用的方法
/*
var h=document.getElementById("hide");
var p=document.getElementById("pic");
//$(h)可以使JS原生的对象转换成jQuery对象
$(h).click(function(){
$(p).hide();
});
*/
});
加油啊~~