html - How to Select 'id' attribute of a <div> using jQuery -
sorry if question similar other questions asked, after searching through have not expected results.
i have more 1 div tag in page like:
<div id='slider1'>&@slider@&</div> <div id='slider2'>&@slider@&</div>
i using jquery select id attribute of div whoes value &@slider@& need id later purpose.
i have tried using [attribute=value] selector isnt working expected in case
function showtext() { alert($("[text='slider']").prop('id')); }
i calling function on event, problem getting "undefined" in alertbox. going wrong.
even tried using
function showtext() { alert($("[text='slider']").attr('id')); }
still getting same "undefined" result
thank in advance
you need use contains selector since want test text content of div
alert($("div:contains('slider')").prop('id'));
your selector $("[text='slider']").prop('id')
tries find element attribute text
, value slider
, <div text="slider"></div>
Comments
Post a Comment