Resize window removeClass / addClass
Hi everyone, I'm really super new to coding and after some classes at codecademy I'm now doing some exercises on my own to eventually build up my own website.
At the moment I'm trying to have js remove a class from a div and add a second class according to the window width (obviously, unsuccessfully)
Here's my attempt
- $(window).resize(function(){
- var st = $('.standard');
- var al = $('.align-left');
-
- if ($(window).width() < 600) {
- st.removeClass('standard');
- st.addClass('align-left');
- }
- });
-
- $(document).ready(main);
On the html file I've included the following just before the closing </body> tag and my js file is saved as app.js in the main folder.
- <scrpt src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
- <script src="app.js"></script>
Hope to find some answers! I thank you in advance for your help!
antonio