小编Dep*_*ted的帖子

使用单击的类查找div的ID

我有几个带有class ="big_square"的盒子它们都有ID,它们是通过一些Java调用Oracle DB来动态生成的,基于它来点击,我希望获得特定的元素ID并将其作为变量返回下一个电话

这是HTML:

<DIV style="DISPLAY: block" id=big_square_container>
<DIV id="2" class=big_square></DIV>
<DIV id="3" class=big_square></DIV>
<DIV id="4" class=big_square></DIV>
<DIV id="5" class=big_square></DIV>
<DIV id="6" class=big_square></DIV></DIV>
</DIV>
Run Code Online (Sandbox Code Playgroud)

和我试图找到ID的jquery:

$(".big_square").click(function(){
    $(".big_square").animate({opacity: .4}, 'fast', 'linear', function() {
      }); 
    $(this).animate({opacity: 1}, 'fast', 'linear', function() {
      }); 
   var x = $(this).getElementbyID();
    console.log(x);
    response.setAttribute("x",x);
});
Run Code Online (Sandbox Code Playgroud)

我猜这个程序在我引用一个类时不知道"这个"是什么,但它仍然应该做一些事情,比如在每个.big_square上执行内部代码,似乎什么都没发生.任何帮助表示赞赏.

html javascript jquery

2
推荐指数
1
解决办法
175
查看次数

标签 统计

html ×1

javascript ×1

jquery ×1