Leo the lion Leo the lion - 1 month ago 5
Javascript Question

How to get inner html of li via id of parent div?

I just want to get inner html of li which is in div. Please see my code

<div id="tabs" style="border:none !important;">
<ul>
<li><a href="#tabs-1" class="active">Flight</a></li>
<li><a href="#tabs-2">Hotel</a></li>
<li><a href="#tabs-3">Car Rental</a></li>
<li><a href="#tabs-4">Cruise</a></li>
</ul>
</div>


Not sharing full code as no need. Is there a simple way to get inner html of li using the parent div id(tabs).

Answer
$(document).ready(function(){
    $("#tabs li").each(function(){
        alert($(this).html());
    });
});

http://jsfiddle.net/t2o3vppa/1/

Comments