How can I access the header tags in an accordion. i.e Sample 1, Sample 2 and Sample 3.
I have tried using following ways for accessing with no success.
$("#accordion div h3 a").text()
or
alert($("#accordion div h3").text())
gives only last accordion i.e.
alert($("#accordion div a").text())
gives output as clickhereclickhere…
HTML:
<div id="dia">
<div id="dialog" title="Detailed FeedBack ">
<div id="accordion">
<h3><a href="#">sample 1</a></h3>
<h3><a href="#">sample 2</a></h3>
<h3><a href="#">sample 3</a></h3>
</div>
</div>
</div>
your
#accordionis your div so all you need is thisor you can just use
depending on what your structure/requirements are
or even more specific
It will return an array of jquery objects which you can retrieve either using
[index]// <– dom element – allows use of native dom methodsex.
$("#accordion > h3 > a")[0]// <– gets first elementor
.eq(index)// <– jquery object which allows use of jQuery methods + chainingex.
$("#accordion > h3 > a").eq(0)//<– gets first element