Created
May 26, 2010 15:03
-
-
Save kirbysayshi/414601 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul id="mealSelection" class="open"> | |
<li> | |
<a href="#" class="selectItem item0"> | |
<img src="" alt="" /> | |
<p>1 in 6 families won't be sitting down to dinner tonight.</p> | |
</a> | |
</li> | |
<li> | |
<a href="#" class="selectItem item1"> | |
<img src="" alt="" /> | |
<p>Without a healthy breakfast, kids can't succeed at school.</p> | |
</a> | |
</li> | |
<li> | |
<a href="#" class="selectItem item2"> | |
<img src="" alt="" /> | |
<p>34% of American families have to choose between lunch and medicine.</p> | |
</a> | |
</li> | |
</ul> | |
<script type="text/javascript"> | |
$.fn.extend({ | |
HSelect: function(options) { | |
var _defaults = { | |
}; | |
var _settings = $.extend({}, _defaults, options); | |
return this.each(function() { | |
var $list = $(this); | |
var $items = $list.find('li:has(a.selectItem)'); | |
var selectedIndex = 0; | |
$(this).delegate('li:has(a.selectItem)', 'click', function(e){ | |
e.preventDefault(); | |
if($list.hasClass('open')){ | |
selectedIndex = $(this).index(); | |
console.log( selectedIndex ); | |
} else { | |
} | |
$list.toggleClass('closed open'); | |
}); | |
}); | |
} | |
}); | |
$("#mealSelection").HSelect(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment