<li title="1"><span onclick="photo_del('<%#Eval("id")%>');"></span></li>
function photo_del(){
怎么写能获取到span的父级的li里的title的值,或者怎么能穿一个this过来。
因为$(this).parent()取不到值
}
不能用ID 不能用CLASS
function photo_del(){
怎么写能获取到span的父级的li里的title的值,或者怎么能穿一个this过来。
因为$(this).parent()取不到值
}
不能用ID 不能用CLASS
function photo_del(obj){
alert($(obj).parent().attr("title"));
}
<html>
<head>
<title>MyHtml.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
function photo_del(item){
alert($(item).parent('li').attr('title'));
}
</script>
</head>
<body>
<li title="1"><span onclick="photo_del(this);">ggggg</span></li>
</body>
</html>
<head>
<title>测试</title>
<script language="javascript" src="jquery.js"></script>
<script language="javascript">
function photo_del(obj) {
alert(obj.parentNode.getAttribute("title"));
}
</script>
</head>
<body>
<ul>
<li title="1"><span onclick="photo_del(this);">aaaa</span></li>
</ul>
</body>
</html>
function photo_del(obj1,obj2){alert($(obj1).parent().attr("title"));
}
.....