3

This might be very stupid, but I am not sure where I am wrong. I found jQuery 'resize()' not work at all. Check this fiddle: http://jsfiddle.net/FefFW/1/

<div id="log"></div>

jQuery:

$(function(){ $('#log').append('<h3>event log</h3><hr/>'); $('window').resize(function(){ $('#log').append('<p>resizing...</p>'); }); }); 

3 Answers 3

6

"window" is not a selector; there is no <window> element.

You want $(window).

Sign up to request clarification or add additional context in comments.

Comments

4
$(function(){ $('#log').append('<h3>event log</h3><hr/>'); $(window).on('resize', function(){ $('#log').append('<p>resizing...</p>'); }); })​; 

FIDDLE

Comments

-1

Have you remembered to put it within $(document).ready(function() { }); ?

And yeah, like the rest just noted when watching the fiddle 'window' is wrong.

1 Comment

You don't need that. window always exists.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.