jquery en el método que no funciona con la ventana o el documento

Pretty simple code:


<div id="wrap" style="background-color:gray; height:2000px;">



<script type="text/javascript">


    $(document).on('mouseup', function(e) {
         console.log(" mouse up \n");



Reemplacé $(document) con $(window) pero sin efecto.

Navegador: FF 13.0

Cómo hacer que funcione ?


OMG, I used scroll instead of clicking the mouse to get the 'mouseup' event. What a silly mistake !!!

preguntado el 31 de julio de 12 a las 13:07

did you include jquery ? -

Funciona para mi: jsfiddle.net/USgbR -

actually on detecting mouseup, a div is intended to bounce. -

@helmus, jquery included -

jsfiddle.net/sfDAk/1 funciona bien -

2 Respuestas

I works fine here http://jsfiddle.net/GXrPp/2/

Does you JQuery reference loads correctly ?

Edit: Here is my result (in FF14) Resultado

Respondido 31 Jul 12, 14:07

i think it does, otherwise there would be error message in console - istiaque ahmed

you used no html to get any scroll - istiaque ahmed

I added html, still no result. - istiaque ahmed

You should handle the event on document.body.
document y window are not DOM elements and do not receive normal events.

Respondido 31 Jul 12, 13:07

I agree with the sentiment of this answer, however jQuery is hand-holding enough to allow the binding of mouse events to document - what the OP posted should (and seems to) work. - Mitia

what kind of elements are document and window then? what type of events do those receive? - istiaque ahmed

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.