如何在jquery中获得UL LI值?

I am trying to get ul li listbox value in function but i cant find way.

My code is like that.

<ul class="dropdown-menu" id="newloc">
    <?php
    $res_add = DB::table('res_br')->where('email',$user_email->email)->get();

    if(count($res_add) != "") {
        foreach($res_add as $rr1) { 
        ?> 
            <li value="<?= $rr1->street;?>"><?= $rr1->street;?></li>
        <?php    
        }
    }
    ?>
</ul>

<button type="button" class="btn btn-block btn-primary" data-dismiss="modal" onClick="buildorder()" >Build Your Order</button>

My jquery function is like that

function buildorder() {
    var radio =   $("input[name='newradio']:checked").val();
    var location = $(this).find('li');

    console.log(li.text());
    alert(radio);
    alert(location);
}

can some help me.to get location variable.

Let's fix this code first:

 <ul class="dropdown-menu" id="newloc">
 <?php
     $res_add = DB::table('res_br')->where('email',$user_email->email)->get();
     if(count($res_add) != "")
     {
        foreach($res_add as $rr1)
        {   
            echo '<li value="'.$rr1->street.'">'.$rr1->street.'</li>';
        }
     }
?>
</ul>

<button type="button" class="btn btn-block btn-primary" data-dismiss="modal" onClick="buildorder()" >Build Your Order</button>

Now your code outputs li-elements based upon the foreach.

Next the button code:

function buildorder()
{

      var radio =   $("input[name='newradio']:checked").val(); //this refers to an input that is not in this post, but I assume this refers to a location in the list.
      var location = $('#newloc').find('li'); //no this, let's use the id

      console.log(location.text()); //this will list all the li elements and there textContent

      alert(radio);
      alert(location);

}

This only fixes the code and will give you information from the lis. However since we don't know more about your code I can't help you further with selecting the correct li.

You can even assign the click handler to the button with jQuery.

$('button.btn.btn-primary').click(buildorder);

Use this code ,hope this will help

$("#newloc li").click(function() {
alert(this.id); 
alert($(this).html()); 
alert($(this).text()); 

});