Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change $(document) width using jquery?

Tags:

html

jquery

css

I'm new to jQuery and HTML so probably this is a very dumb question, but I'm just curious if it is possible to change document or window width using jQuery?

Is something like this possible:

$(document).ready(function() {
   $(document).width( $(window).width() );
});

Thank you

like image 388
Eugene Gordin Avatar asked Feb 26 '26 20:02

Eugene Gordin


1 Answers

As I understand it, $(document).width() is read only and will not update the width value. You may have better luck with:

$('body').width( $(window).width() );

Although this would have no effect unless the root element of your document/page was styled to be larger than the viewport (would eliminate horizontal scrolling).

like image 128
Lou Avatar answered Feb 28 '26 11:02

Lou



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!