CSS - resize - remove javascript

I know how to.. Remove a using CSS:

@media only screen and (max-width: 1600px) {
    #shout {
        display: none;

    }
}   

But I want to know how to remove a javascript with resize if possible? With javascript I mean this:

<script src="assets/js/minimap.js"></script>

... The minimap script also has a css file , called minimap.css. So I could manipulate that file too if needed.

Answers 1

  •     $(window).resize(function(){
    
        if(window.innerWidth<400){
        $('#abc').css({'display':'none'});
        }
        else 
        $('#abc').css({'display':'block'});
        }).resize();
    #abc{
    width:100px;
    height:100px;
    background:#545454;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div id="abc"></div>

    Alternatively using javascript:

    window.addEventListener('resize',checkResize)
    function checkResize(){
    if(window.innerWidth<400){
    document.getElementById("abc").style.display="none";
    }
    else
    document.getElementById("abc").style.display="block";
    
    }
    checkResize();
    #abc{
    width:100px;
    height:100px;
    background:#545454;
    }
    <div id="abc"></div>


Related Articles