a3onstorm a3onstorm - 4 months ago 6x
HTML Question

jquery page resize not working

Hey guys I'm just starting out with JQuery so I'm an utter noob, but I've been following the codecademy tutorial and am trying to implement a page resize function to fit into a resized browser. However nothing is working inside the script tags with jquery inside - even alerts aren't happening. The first script runs fine and says hi, but neither of the other two alerts work, nor any of the Jquery stuff. I'm not sure if it makes a difference, but there are two soundcloud widgets on the page as well, one which is a programmable widget.

<script type="text/javascript">alert("Hi");</script>

<script type="text/javascript">
$(document).ready(function() {
$(window).resize(function() {
if ($(window).width() < 1020) {
$('#page').css("width", "500px");

Apart from figuring out why nothing happens, I'd also like to know if this resize thing works.


You got syntax error : window.resize should close with }); not )};

And be sure you called jQuery first.

By the way : why don't you simply use Media Queries ?

@media screen and (max-width: 1020px) {
 #page {
   width: 500px;