Reputation: 95
I use some JavaScript in my menu when user scroll my webpage. Here is example
All works fine but i want to dissable that effect in media query. Can i disasbel JavaScript in media query ..
@media only screen
(max-device-width : 360px) {
//dissable JavaScript
}
Upvotes: 0
Views: 122
Reputation: 2216
you cant disable JavaScript, but you can detect the resolution and not write the JavaScript.
Upvotes: 0
Reputation: 13003
Can i disasbel JavaScript in media query ..
No, you can't, neither with CSS Media rule nor with any other programming mechanism. JavaScript activation is a matter of the user preferences in the web-browser.
But you can always use workarounds like this one: how to disable javascript for responsive design
Update:
You can easily test the current CSS media type using jQuery and accordingly to activate your JS code:
var media = $('link[href$="yourStyleFile.css"]').attr('media');
Upvotes: 2