I want to get the click event on the li element using jQuery. But unable to get it. FoundationJs framework is used for the frontend.
HTML code:
<div class="entry-fee margin-auto" style="padding: 10px 10px 0px 10px; background-color: white;">
<div class="row container" style="padding: 5px;">
<h4 style="text-align: left; font-weight: bold; font-size: 1em;">Entry Fee</h4>
<div class="select-box">
<ol class="select" id="coins">
<% for(var i=0; i < data.coinOptions.length; i++) { %>
<li class="ui-state-default <%= i == 0 ? 'ui-selected' : '' %>" data-value="<%- data.coinOptions[i] %>"><%= (data.coinOptions[i] == 0 ? "FREE" : data.coinOptions[i] + " Coins") %></li>
<% } %>
</ol>
</div>
</div>
</div>
The jquery code snippet below works on clicking the container but not on li tag
$(".entry-fee .container").click(function (event) {
event.preventDefault();
console.log(event.currentTarget);
})
None of the below work when I click on the li tags
$(".entry-fee .container .select-box").click(function (event) {
event.preventDefault();
console.log(event.currentTarget);
})
$(".entry-fee .container .select-box li").click(function (event) {
event.preventDefault();
console.log(event.currentTarget);
})
$("#coins li").click(function (event) {
event.preventDefault();
console.log(event.currentTarget);
})
But I noted one thing that if I fire the event manually using
$(".entry-fee .container .select-box li").click()
in chrome console it works, which means the event listeners are bound to the elements. What can be done here to make it work properly? Let me know if any more info is required.