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 error 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.)