<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(function(){
$("#up").click(function(){
var afirst=$(".imglist a:first-child").html();
alert(afirst);
});
});
</script>
</head>
<body>
<a href="javascript:void(0);" id="up">往前走</a>
<div class="imglist">
<a href="javascript:void(0);" title='/UpLoadFiles/memberpic/2012071211033214.jpg'>
111
</a>
<a href="javascript:void(0);" title='/UpLoadFiles/memberpic/2012071211032801.jpg'>
222
</a>
<a href="javascript:void(0);" title='/UpLoadFiles/memberpic/2012071211031878.jpg'>
333
</a>
<a href="javascript:void(0);" title='/UpLoadFiles/memberpic/2012071208381331.jpg'>
444
</a>
<a href="javascript:void(0);" title='/UpLoadFiles/memberpic/2012071208380428.jpg'>
555
</a>
</div>
<a href="javascript:void(0);" id="next">往后走</a>
</body>
</html>
问题是,现在只能取到 111
我想取到 :<a href="javascript:void(0);" title='/UpLoadFiles/memberpic/2012071211033214.jpg'>
111
</a>
求同志们赐教……
$.extend($.prototype, { htmlCode:function(){ var div = $('<div></div>'); this.appendTo(div); return div.html(); } });
$('#id').htmlCode();
什么也不说,你赢了……
但是,取得了之后就在页面消失了……
@iisp:
$.extend($.prototype, { htmlCode:function(){ var div = $('<div></div>'); this.clone().appendTo(div); return div.html(); } });
$('#id').htmlCode();
var afirst=$(".imglist:first-child").html();这样试试
返回null
@iisp: $(".imglist> a:first").html();
@荒野的呼唤: 返回111