If I have code like this:
<div class="container">
<span class="pID">12342123</span>
<a href="#" class="but">click here</a>
</div>
<div class="container">
<span class="pID">98765432</span>
<a href="#" class="but">click here</a>
</div>
<div class="container">
<span class="pID">2342342</span>
<a href="#" class="but">click here</a>
</div>
How do I make it so if the link is clicked on, go to the pID and grab the # within the a's own container?
$('.but').on('click',function(){
var pID = $(this).parent('pID').text(); ?
});
For your information, I don't have any control of putting the PID in the anchor.