-1

On Button Click i want to get the value of li.

<ul class="nav nav-tabs">
  <li class="one">One Code</li>
  <li class="two">Two Code</li>
  <li class="three">Three Code</li>
</ul>

<button type="submit"  id="btnid" onclick="btnclick();">Submit</button>
MIlan Modh
  • 95
  • 9

2 Answers2

2

Try this-

function btnclick() {
    var arr = [];
    $("ul.nav").find("li").each(function () {
        arr.push($(this).html()) //I don't know what you want, I am assuming the Html
    })
    alert(arr);
}

DEMO

vikrant singh
  • 2,091
  • 1
  • 12
  • 16
1

you can access each li like this with the jquery selector

$("a",CLASS_NAME,"li", "ul").text()

wich CLASS_NAME is .one .two .thre....

CollioTV
  • 684
  • 3
  • 13