Domanda

I have a foundation drop-down like below

<a href="#" data-dropdown="drop1" id="dateTitle">Date Range  </a>
<ul id="drop1" class="f-dropdown small date-menu" drop-down-content>
    <li id="custom">Custom</li>
    <div id="customContainer"></div>
    <li id="today"> Today</li>
    <li id="yesterday">Yesterday</li>
    <li id="sundaytoToday">This Week(Sun-Today)</li>
    <li id="montoToday">This Week(Mon-Today)</li>
    <li id="lastSevenDays">Last 7 Days</li>
    <li id="lastSuntoSat">Last Week(Sun - Sat)</li>
    <li id="lastMontoSun">Last Week(Mon - Sun)</li>
    <li id="lastBusinessWeek">Last Business Week(Mon - Fri)</li>
    <li id="lastFourteenDays">Last 14 days</li>
    <li id="thisMonth">This Month</li>
    <li id="lastThirtyDays">Last 30 days</li>
    <li id="lastMonth">Last Month</li>
    <li id="allTime">All Time</li>
    <hr>
    <li id="compare">Compare
        <div class="onoffswitch">
            <div class="onoffswitch">
            <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch">
            <label class="onoffswitch-label" for="myonoffswitch">
            <div class="onoffswitch-inner"></div>
            <div class="onoffswitch-switch"></div>
        </label>
    </div>
    </li>
    <div id="extraContainer"></div>
    <div align="center"><button class="date-picker-submit">Apply</button></div>
</ul>

When user clicks on a list item and then the apply button at the bottom, I want to grab the selected item of the list

I'm not getting how to do it

$('.date-picker-submit').click(function(){
  //get the selected value
});
È stato utile?

Soluzione

do like this:

$('#drop1 li').click(function(){
     $('#drop1 li').removeClass("selected");
     $(this).addClass("selected");
});

now on button click:

$('.date-picker-submit').click(function(){
    $('#drop1 li.selected').text();
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top