Ryan Ryan -3 years ago 240
jQuery Question

jquery Get UL innerhtml

I'm trying to get the innerhtml of the UL after clicking on a li, any ideas?

This is what i have so far which gets the innerhtml of the li.

$('#Modbutton').click(function() {

var litype = document.getElementById('Modbutton').innerHTML;
alert (litype);

});

Answer Source

A simple way is using closest

 $('#Modbutton').click(function() {       

      alert($(this).closest('ul').html())
   });

API Documentation Ref https://api.jquery.com/closest/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download