I have the following list withing an unordered list with id #sortable1, what I want to achieve is whenever a li element is clicked withing < ul id="sortable2"> an onclick event should happen and alert the id from the li element that was clicked. I have one element also within the unordered list that should not be clickable with the class="emptyMessage"
I got stuck and dont know how to proceed
So far I have
<ul id="sortable1" class="connectedSortable ui-sortable">
<li class="ui-state-default" id="1">Name1</li>
<li class="ui-state-default" id="2">Name2</li>
<li class="ui-state-default" id="3">Name3</li>
<li class="ui-state-default" id="4">Name4</li>
<li class="ui-state-default" id="5">Name5</li>
<li style="display: list-item;" class="emptyMessage">No more contacts available</li></ul>
My JQUERY code
$("#sortable1 li").click(function() {
alert('Clicked list.'+$(this).value);
});
This should do it:
$("#sortable1 li").not('.emptyMessage').click(function() {
alert('Clicked list. ' + this.id);
});
Demo: http://www.jsfiddle.net/gztRq/2/
$("#sortable1 > li.ui-state-default").click(function() {
alert("Clicked list " + $(this).attr("id"));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With