Alternatively, instead of unbinding the event, you could have your event handler check for some condition:
$('div#topLineHover').bind('mouseover', function() { if($('#topLine').is(':hidden')) { $('#topLine').slideDown('slow'); } }); Also, when selecting by ID, no need to specify a tag name. So div#topLineHover should be #topLineHover. --Erik On 5/29/07, Gordon <[EMAIL PROTECTED]> wrote:
Yeah, you have to repeat the code. You could put the code in a function though. function doSlide () { $('#myLine').slideDown ('slow'); } $('div#topLineHover').bind('mouseover', doSlide); On May 29, 11:03 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Does that mean i have to repeat the code or is there a way to do it without? > > Gordon wrote: > > The same way you bound it in the first place. > > > On May 29, 8:12 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > >> Thanks Erik, > > >> But how do i rebind something which has been unbound? > > >> Erik Beeson wrote: > > >>> How about: > > >>> $('div#topLineHover').one('mouseover', function() { > >>> $('#topLine').slideDown('slow'); > >>> }); > > >>> Or: > >>> $('div#topLineHover').bind('mouseover', function() { > >>> $('#topLine').slideDown('slow'); > >>> }); > >>> And: > >>> $('div#topLineHover').unbind('mouseover'); > > >>> --Erik > > >>> On 5/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > >>>> Hi all, > > >>>> I'm struggling to understand how to remove an event listener in jquery. > > >>>> I have this basic code: > > >>>> $('div#topLineHover').hover(function() > >>>> { > >>>> $('#topLine').slideDown('slow'); > >>>> }); > > >>>> Now, once the topLine div has appeared, i want to stop this code from > >>>> working any more. > > >>>> At a later point, upon another event being triggered, i'd like to > >>>> reactivate this code > > >>>> I'm really at a loss on this and i've searched high and low! Any > >>>> help would > >>>> be greatly appreciated. > > >>>> Thanks