gpt4 book ai didi

jquery - 如何通过单击加号图标获取类属性值

转载 作者:行者123 更新时间:2023-12-01 04:44:03 25 4
gpt4 key购买 nike

我有很多 TreeMenu_Content 的 div 类,因为它是一个动态屏幕。

当点击加号图标时。

我的问题是,是否可以获得lastItm_Wrap id值?

我尝试过

$(document).on('click', '.icon-plus', function(event) {

var idval = $(this).closest('div').find('.lastItm_Wrap').attr('id');

alert(idval);
});

是否可以在不使用TreeMenu_Content的情况下获取lastItm_Wrap属性id

请让我知道如何带来这个值。

http://jsfiddle.net/bxbnkq64/

最佳答案

你很接近:

$(document).on('click', '.icon-plus', function(event) {
var idval = $(this).parents('.lastItm_Wrap').first().attr('id');
alert(idval);
});

JSFiddle

关于jquery - 如何通过单击加号图标获取类属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32720110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com