87,907
社区成员
发帖
与我相关
我的任务
分享
<div class="hello">
<div class="open"><img src="../pictrues/hello.png"></div>
</div>
$(this).find("img").attr("src")
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="js/jquery-1.3.2.min.js"></script>
</head>
<body>
<div class="hello">
<div class="open"><img src="image/24k.gif"></div>
</div>
<strong></strong>
</body>
<script language="javascript">
$(function()
{
$('div.hello').click(function()
{
alert("图片路径是:"+$('div.hello').find("img")[0].src);
});
});
</script>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script type="text/javascript" src="jquery-1.2.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".hello").click(function(){
var sr = $(".hello .open img").attr("src");
alert(sr);
});
});
</script>
</HEAD>
<BODY>
<div class="hello" style="width:200px;height:100px;background:red">
<div class="open"><img src="http://c.csdn.net/bbs/t/5/i/pic_logo.gif"></div>
</div>
</BODY>
</HTML>
$(".hello .open img").attr("src")
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script>
$(document).ready(function() {
alert($("div[@class=hello] div[@class=open] img").attr("src"));
});
</script>
</head>
<body>
<div class="hello">
<div class="open"><img src="../pictrues/hello.png"></div>
</div>
</body>
</html>