Get text and id from an li element on click with pure JS
<p>I've been stuck with this for several days and I can't solve it.</p>

<p>I've done it with jQuery with no problem, but I need it in pure JS.</p>

<p>This is how my list is generated.</p>

<pre><code>function get_friends(items){


if(items != undefined){
    if (items.length != 0){
        var html_friends_list = "";

        for(var count = 0; count &lt; items.length; count++){
            if(items[count].subscription == "both"){
                var display_name = Strophe.getNodeFromJid(items[count].jid);

                html_friends_list = html_friends_list + "&lt;li style='font-size:19px' id='open_chat-" + items[count].jid + "'&gt;" + "&lt;a href='chat-js/index.html'&gt;" + display_name + "&lt;span class='block-list-label' id='" + items[count].jid  + "_unread_messages" + "'&gt;0&lt;/span&gt;&lt;span class='block-list-label' id='" + items[count].jid  + "_change_status" + "'&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;";

             }
        }

        document.getElementById("friends-list").innerHTML = html_friends_list;
</code></pre>

<p>As a said I want to save the value of the text and the id of any li element clicked.</p>

<p>Regards</p>