Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Changing something based on the browser window width

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27026
    RohanJM
    Member

    Hi all,
    I know there’s a simple solution but I cant find it.
    How do I change the css of something if the browser window width is less than a certain number of pixels… using jquery.

    Thanks
    Rohan Merchant

    #67858
    BaylorRae
    Member

    Try this

    Code:
    if( $(window).width() < 900 ) { console.log("Less"); }else { console.log("More"); }
    #67861
    RohanJM
    Member

    Thanks

    #67896
    BaylorRae
    Member

    You might want to add this in case the browser is resized.

    Code:
    // On Resize
    $(window).resize(function() {
    if( $(this).width() < 900 ) { console.log("Less"); }else { console.log("More"); } });
Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.