javascript - Short jQuery works, everything else goes blank -


i'm trying show "test" depending on screen size:

<script type="text/javascript"> jquery(function( $ ){ if($(window).width() >= 960){ document.write('test'); } }); </script> 

due jquery-conflict, had put script within "jquery(funcion..."

so script works. however, entire site loads normally, goes blank once script executed, "test" showing on screen. why?

once document ready fires, if use document.write() again, document rewritten, if want append text can use append()

note: document.write writes document stream, calling document.write on closed (loaded) document automatically calls document.open which clear document.

jquery(function( $ ){ if($(window).width() >= 960){ $('body').append('test') } }); 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -