I have a certain DIV structure with an anchor tag in between somewhere. On click of the link, I need to fetch the value of another span element within the parent div and do something, (say, alert it).
The html is like this :
...
<div id="div1">
...
<span>This is reqd</span>
...
<a href="#">Click Me </a>
...
</div>
...
The entire div is repeated many times in the page.
When I click on the a I want to alert “This is reqd”.
Can the HTML be searched like this?
For a single span element, it should be pretty easy,. Just call a myFunction(this) on click of the link and manipulate the DOM like this :
Hope this works. It did for me !!