在我的网站中,我以这种方式设置了一些元素: 1. class='up' id='1' 2. class='up' id='2' 3. class='up' id='3' 4 .class='up' id='4' etc..(元素数量未知)
我的问题是尝试在 javascript 中识别它们时。我尝试使用以下代码(JQuery)来选择特定元素:
$('.up#'+ id)....
然而,这似乎失败了。id
你看到有一个变量传递给处理这个的函数。它是从单击事件传递的,并以这种方式设置:
$('.up').click(function(){
some_function(this.id);
});
some_function
接受这个 id,它是传递给它的唯一参数。
我不知道为什么会失败,感谢您的帮助!