March 28, 2012
Delegate for jQuery 1.3.2
Question by estrar
I got this code today that works for jQuery v7. The problem is that it need to work for 1.3.2 as well. How would I translate it?
$(document).ready(function() {
$("ul#dropdown li ul").hide();
$("ul#dropdown").delegate( 'li', 'click', function () {
if (!$(this).parent().is("ul#dropdown") ) {
return false;
}
$(this).siblings('.' + "current").removeClass("current").children('ul').slideUp('fast');
$(this).addClass("current").children('ul').slideDown('fast')
});
});
Answer by Starx
The only option for delegation in 1.3
is live() method
$("ul#dropdown li").live('click', function () {
if (!$(this).parent().is("ul#dropdown") ) {
return false;
}
$(this).siblings('.' + "current").removeClass("current").children('ul').slideUp('fast');
$(this).addClass("current").children('ul').slideDown('fast')
});