Jquery 获取圆形滑块中的上一个元素
Jquery 获取圆形滑块中的上一个元素,jquery,css,Jquery,Css,我有一个图像滑块,通过点击一个图像,我想得到所有以前的图像元素ID,它们都写在html页面上。当我尝试打印之前的所有元素时,由于循环div,所有img都被打印。 例如,如果我单击图像#5,我只想得到1、2、3、4和5。下面的代码返回4、3、2、1、12、11、10、9等等 var ids = t.prevAll().removeClass('t2').addClass('t1').map(function(){ return this.id; }).get().join(); consol
我有一个图像滑块,通过点击一个图像,我想得到所有以前的图像元素ID,它们都写在html页面上。当我尝试打印之前的所有元素时,由于循环div,所有
img
都被打印。
例如,如果我单击图像#5,我只想得到1、2、3、4和5。下面的代码返回4、3、2、1、12、11、10、9等等
var ids = t.prevAll().removeClass('t2').addClass('t1').map(function(){
return this.id;
}).get().join();
console.log(ids);
$(document).ready(function () {
/* Reading the data from XML file*/
$.ajax({
type: "GET",
url: "photos.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('item').each(function(){
var path = $(this).attr('path');
var width = $(this).attr('width');
var height = $(this).attr('height');
var id = $(this).attr('id');
var alt = $(this).attr('alt');
var longdesc = $(this).find('longdesc').text();
var description = $(this).find('desc').text();
$('#myImageFlow').append('<img src="'+path+'" id='+id+' height="'+height+'" width="'+ width+'" longdesc="'+longdesc+'" alt="'+alt+'"/>');
imgArr[i] = description;
imgFront[i]=longdesc;
backimg[i]=longdesc;
frontimg[i]=path;
i = i+1;
});
var id=t.prevAll().removeClass('t2').addClass('t1').map(函数(){
返回此.id;
}).get().join();
控制台日志(ids);
$(文档).ready(函数(){
/*从XML文件读取数据*/
$.ajax({
键入:“获取”,
url:“photos.xml”,
数据类型:“xml”,
成功:函数(xml){
$(xml).find('item').each(function(){
var path=$(this.attr('path');
var width=$(this.attr('width');
var height=$(this.attr('height');
var id=$(this.attr('id');
var alt=$(this.attr('alt');
var longdesc=$(this.find('longdesc').text();
var description=$(this.find('desc').text();
$('#myImageFlow')。附加('');
imgArr[i]=描述;
imgFront[i]=longdesc;
backimg[i]=longdesc;
frontimg[i]=路径;
i=i+1;
});
什么是t
?你能在@Dogbert t=$(这个)…任何点击的图像都是实际完整的代码吗?你没有给t
@Dogbert分配什么?