I have been looking at some other examples, but they're not quite the same unfortunately. I am trying to delete some data onclick (omitted that part here, only need the id for that). Problem is that it returns undefined for the id I want.
function deleteMessage(){
var $currentId = $(this).closest(".ulrecords").attr('id');
alert("ID: " + $currentId)
}
The method is being called as follow
<a href="javascript:deleteMessage();" id="amessage">
And the HTML looks like this
<ul class="chat-messages">
<ul id="msg_1234567890_a1bs2e" class="ulrecords">
<li>
John
<span>27 minutes ago</span>
<a href="javascript:deleteMessage();" id="amessage"> X</a>
</li>
<li id="limessage">
Some message here
</li>
</ul>
<ul id="msg_9234742878_73bhad" class="ulrecords">
<li>
John
<span>28 minutes ago</span>
<a href="javascript:deleteMessage();" id="amessage"> X</a>
</li>
<li id="limessage">
Some other message here
</li>
</ul>
</ul>
So when i click on the in one of the ul's I want to obtain that Hope anyone can point me in the right direction
` seems semantically incorrect (cf. http://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list) – somethinghere Mar 14 '16 at 12:20