finding a div parent element with a certain property
When my slider moves I have to catch the id of the div containing data-role="page"
<div data-role="page" data-theme="a" id="buttons">
<div data-role="content">
<label for="slider1">Slider 1</label>
<input type="range" name="slider1" id="slider1" value="0" min="0" max="100" />
</div>
</div>
And then when the slider event triggers I execute this:
console.log($(this).find("div").filter('[data-role=page]').attr("id"));
but doesn't work. Any ideas开发者_JAVA技巧? Thanks in advance!
Try .closest
if this
is a child of the div
you want:
console.log($(this).closest('div[data-role="page"]').attr("id"));
精彩评论