159
rated 0 times
[
164]
[
5]
/ answers: 1 / hits: 29498
/ 10 Years ago, wed, july 23, 2014, 12:00:00
I have a ul
which is <ul>
list, I would like to get the selected value in different function and the list looks like below
<ul class=dropdown-menu role=menu id=ChooseAreaList>
<li><a href=#>Select Destination</a></li>
<li><a href=#>HSR</a></li>
<li><a href=#>Bommanahalli</a></li>
<li><a href=#>Kormangala</a></li>
</ul>
by applying some CSS,JS
I am able to get selected value of list like this...
$(.dropdown-menu li a).click(function(){
var selText = $(this).text();///User selected value...****
$(this).parents('.btn-group').find('.dropdown-toggle').html(selText+' <span class=caret></span>');
});
but if i am trying to get this selected value in different function its not working...like this
function BusinessLogic(){
var selText = $('.dropdown-menu li a').text();
alert(Its displaying Entire List+selText);
}
How to do I get selected value of that list in different function?
More From » jquery