Sometimes we need to set a div whose width is the entire browser width. Of course, we can use relative layout to do this, but we can also use jquery to achieve it.
jquery test <script> <br>var browser_width = $(document.body).width(); <br>$("div.show").css("width",browser_width ); <br>$(window).resize(function() { <br>browser_width = $(document.body).width(); <br>$("div.show").css("width", browser_width); <br>}); <br></script>
We use $(document.body).width() to get the browser content When loading the page, we initialize the width of the div to the width of the browser page, and then whenever the browser is resized, the resize function will be triggered. At this time, we adjust the width of the div again.