javascript - How to write this in a more sophisticated way? -


This works, but I'm sure it's written more clearly.

  & lt; Script & gt; $ (Document) .ready (function () {$ ('. Col'). CSS ({'height': ($ (document) .height ()) + 'px'}); $ (window) .resize ( Function () {$ ('colonel'). Css ({'height': ($ (document). ()) + 'Px'});})}}  gt;   

I have tried without the first $ ('.cale)' CSS ... and it does not work. So basically what I say to the browser "When the document is ready, resize this div, and resize it at every height change."

this Here is:

  & lt; script & gt; $ (window). Resize (function () {$ ('. Col'). CSS ({'height': ($ (document) ). You can listen to the  resize  event and when the document is ready (); & lt; / script & gt;    If it is done, then it can trigger.  

Other small changes:

  • You can enter document.ready with $ (function () {})
  • Resizing event listener can be made before document.ready , because the window is always the object Is present and you want it Ni quickly requirements can engage.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -