Suppose I have something like this
<div class="xx" data-id="tid">Jumbo Jet</div>
<div class="press"> clickme </div>
<div class="foo">
....
</div>
<div class="xx" data-id="tid">Hello World</div>
<div class="xx" data-id="tid">Red Brown Fox</div>
Is there a jquery function that would search under it (not its child) for a specific id and return back the first result. In this case I should get "Hello World". Will the find method work ? I am doing something like this
$(".press").click(function () {
var item = $(this).find("#tid");
//Get the classname
var name = item.attr('class'); //returns undefined should return xx
//Also how do I return the content ? "Hello World"
console.log(name);
});
Any suggestions on what I might be doing wrong here ?
var item = $(this).next()data-attributes instead.