jquery 如何获取某个标签下面的img标签?
问题描述:
答
var $current = $("#slideshow div.current")
在使用find()方法可以找到子元素然后遍历
$current.find("img").each(function(i){
$(this).width();//就是他的宽度
});
答
var imgArr = $("#slideshow selection img"); //这是一个数组
循环数组分别获取宽度
$.each(imgArr, function(){
alert($(this).attr('width'));
});
答
var img = $('.current img')
答
jquery的选择器和css差不多的,css怎么获取,jquery就怎么获取
比如css支持#slideShow>.curent>img 那么jquery就可以用
$("#slideShow>.curent>img")获取到
还包括子孙选择器 等等
答
[code="javascipt"]
$("#slideshow div.current img").attr('width');
[/code]
我理解的对吗 ?