I hope this isn't a double post, my other one was over 12hrs ago and it never displayed. I'm trying to get the text out of a <p> tag, I can do this if I set an id name, but I don't want to id everything, since with jQuery I don't need to. The premise is I'm clicking a link and it gets two values and inserts them in a texarea. Inserting isn't the problem, just finding the values.
$(document).ready(function(){ $("#comments span h5 a").click(function(){ var author = $(this).parent("span").next("p").text(); alert(author); }) }); <div id="comments"> <div id="5"><span><h4>Minion</h4><h5>(<a href="#">Reply</a>)</h5></ span><br> <p>Back to normal status</p> </div> </div> I'm finding the link, I had an alert test, so I know it works. So I then tried to capture the data in the <p> tag. I just get a blank alert though. I tried without the parent at first, but got nothing. So thought I had to go up to the main tag before calling next, still nothing. While on topic, is there a way to get the value of an id tag? The number 5 will serve importance later.