html lists - Get value of li on click using JQuery -
this first question here, forgive me asked incorrectly. have html view:
<div class="input-group-btn search-panel"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <span id="search_concept">filter by</span> <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu" id="mysearch"> <li><a href="/home/searchplayersregform" id="searchstr" >registration number</a></li> <li><a href="/home/searchplayersview" id="lastname">last name only</a></li> <li><a href="/home/searchplayersview" id="fullname">child's first , last name</a></li> <li><a href="/home/searchplayersview" id="pho">phone number</a></li> </ul> </div> <input type="text" class="form-control" name="searchstr" id="search" placeholder="search term..."> <span class="input-group-btn seach-form"> <button class="btn btn-default" onclick="performsearch(event)" id="searchstr"><span class="glyphicon glyphicon-search"></span></button> </span> </div>
and want use jquery find value in li
function performsearch(event) { alert('i here') var btn_name = $(document).attr('class') var optionform = $(document).closest('li').attr('id'); alert(btn_name + " within " + id);};
am doing wrong? go function can't function pull id in li.
i suggest use class.
then use jquery check if class has been clicked, , use data-livalue value of href can pass.
......
in jquery follows:
$('.liclickedclass').click(function(){ var vref = $(this).data('livalue') alert(vref) # windows.location.href = vref });
Comments
Post a Comment