Hide Div if Screen is Smaller than 1024

Hide Div if Screen is Smaller than 1024

hi there..

i want to hide a floating div if the user screen is < 1024 as it will overlay with my blog content area. i found this jquery on the net i am not sure how to use it.





  1. $(document).ready(function() {


    if ((screen.width>1024)) {
    // if screen size is 1025px wide or larger
    $
    (".yourClass").css('display', 'none'); // you can also use $(".yourClass").hide();
    }
    elseif
    ((screen.width<=1024))  {
    // if screen size width is less than 1024px
    $
    (".yourClass").css('display', 'block'); // here you can also use show();
    }
    });



my first question is, if my floating div class name is sharecontent, should i replace the above script like below? it yes, its not working.



  1. $(document).ready(function() {


    if ((screen.width>1024)) {
    // if screen size is 1025px wide or larger
    $
    (".sharecontent").css('display', 'none'); // you can also use $(".yourClass").hide();
    }
    elseif
    ((screen.width<=1024))  {
    // if screen size width is less than 1024px
    $
    (".sharecontent").css('display', 'block'); // here you can also use show();
    }
    });