So I have a series of 2 nested ul's. When you click on the text (which is in an a tag) in the li, my page makes that editable and adds a save button. clicking the save button needs to give me back the new text inside that li and the id of that li. The id is not a problem. I'm trying to use jQuery's .find to select that anchor tag (which is successful) but i can't seem to get the text from it.
Here is an example of the first list and it's sublists.
<ul class='lists'>
<li class='list1'>
<a class='a list' id='list1'> List 1 Name</a>
<img id='savelist1id' onClick="SaveName(this.parentNode.id)" src='save.jpg'>
<ul class='sublists'>
<li class='sub1'>
<a class='a sub' id='sub1id'> Sub 1 Name</a>
<img id='savesub1id' onClick="SaveName(this.parentNode.id)" src='save.jpg'>
</li>
<li class='sub3'>
<a class='a sub' id='sub2id'> Sub 2 Name</a>
<img id='savesub2id' onClick="SaveName(this.parentNode.id)" src='save.jpg'>
</li>
<li class='sub2'>
<a class='a sub' id='sub3id'> Sub 3 Name</a>
<img id='savesub3id' onClick="SaveName(this.parentNode.id)" src='save.jpg'>
</li>
</ul>
</li>
</ul>
Here's the code for identifying which save button you clicked.
function SaveName(parentid){
$('li').find('a').each(function(){
if (this.id == parentid){
alert(this.id+' '+this.text)
}
}
});
I am wanting this.text to show me the text inside the anchor tags. Help, please?
=========================================================== Edit:
Please excuse this post. The problem was that I was using Jeditable and didn't know that it would put in a form in place of the text, so anything that would call text wouldn't work. Sorry.