开发者

Find an element in a div using the attribute ends selector

I am trying to find hidden element in a div using the attribute ends with selector and I am running into issues.

I have a jQuery object which represents div and I know that my hidden input is in this div and it ends with "-id", but I am not able to locate it.

This is my code

var clickedContainer = $(theThis).parent().parent().parent();
var id = clickedContainer.find([id$='-id']).val();

I get an erro开发者_开发百科r on the second line.

I guess, I don't know how to find an element in a div which is represented by a jQuery object.


You probably need to quote your argument to find():

var id = clickedContainer.find("[id$='-id']").val();

(Just a note: when you say you "get an error", it's usually a good thing to actually say what the error message is.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜