开发者

Why $(parent).children(class) doesn't return element?

开发者 https://www.devze.com 2023-02-24 03:23 出处:网络
var parent = $(this).parent().parent().parent().parent().next().attr(\"id\"); alert ($(\"#\"+parent).child开发者_如何学Goren(\".select_tarif\").get());
var parent = $(this).parent().parent().parent().parent().next().attr("id");

alert ($("#"+parent).child开发者_如何学Goren(".select_tarif").get());

I try to retrieve elements, with parent and class (I can't use only the class, because I have other elements with same class, but variant parent).

The way to retrieve the parent is ugly, but I can't do otherwise (html is generated) and it return what I want.

My problem is, function alert() returns nothing, but it will display element is a select input


Use:

$("#"+parent).find(".select_tarif")


You don't need to use another selector (and find is better)

var parent = $(this).parent().parent().parent().parent().next();

alert (parent.find(".select_tarif").get());
0

精彩评论

暂无评论...
验证码 换一张
取 消