I want to change my text by the current browser width size without having to use refresh like mediaqueries.
I have this code,
It doesnt work, what am i doing wrong?
function checkSize() {
//small-screen
if (window.innerWidth < 1200) {
$("#hello-world").html("Hello World");
}
//end small-screen
}
checkSize();
$(window).resize(function() {
checkSize();
});
Suggestion
Enclose the code inside
$(document).ready();this way:Demo: http://jsfiddle.net/rXERS/