Tuesday, 23 December 2014

jQuery Window Width – Browsers and Responsive Design

jQuery Window Width

jquery window width, you’ll need it if you’re working with Responsive Design and/or need to figure out the width of the browser Window? Are you using a responsive design layout and using viewport, but need a way to determine window width? jQuery width() and jQuery resize() can help.

Responsive Design

With so many devices able to access the internet, Responsive Design is becoming a necessity.   Smart phones, tablets, laptops, and desktop computers have different viewable areas. Viewport is the window size of the device. We’ll use jquery width and resize functions to determine the window width of the screen thus aiding us in our Responsive Design.
To determine the browser window width and if it gets resized we’ll use:
  • jquery width
  • jquery resize
  • window

jQuery Window Width Determined

jQuery .width() returns a numerical value only, i.e.325.  The value is in pixels.  However, .css(width) will return the number and units, i.e. 325px.   We want to use jQuery window width since we’ll test for numerical values later.

var wi = $(window).width(); // Stores the numerical value of the width into the variable "wi"

Window vs. Document vs. Screen

Why window width?  The window “holds” the document. Because the document is what gets loaded into the Window object we’ll use $(window).width().  I also use  jquery window width instead of screen width.  If someone doesn’t have their browser windowmaximized to full screen then it only makes sense to get the width of the window size they are using and not the screen.

$(window).width();   // This will return the width of browser viewport
$(document).width(); // This will return the width of HTML document
$(screen).width(); // This will return the width of the users screen
//Since the document is what gets loaded into the Window object, and the
//browser window may not be maximized to full screen we'll use $(window).width();

jQuery Window Resize

What happens if the window is resized?  Luckily jQuery has a function to test if an object gets resized.  The code below will show the window width when resized.

$(window).resize(function() {
        var wi = $(window).width();
        $("p.testp").text('Screen width is currently: ' + wi + 'px.');

jQuery Window Width

The code below will use jQuery window width to show the initial screen width, but not once it’s resized.

jQuery Window Width Determined Initially and When Resized

We’ll put it all together here.  We’ll use jQuery window width and resize as we did above.  I will provide the HTML to be manipulated further below.

jQuery Window Width HTML

Below is the HTML required. We use the jQuery / javascript code above to manipulate the HTML code below.


  1. Behance - Golpik

    I like your blog thanks for sharing about blog wow

  2. Thank you sir And keep it up More Post And Its A Awesome Web page sir Thank You So Much

  3. I must say you had done a tremendous job,I appreciate all your efforts.Thanks alot for your writings......Waiting for a new 1...Please visit our wonderful and valuable website-

  4. I really enjoyed reading your blog, you have lots of great content.Please visit here:
    Gurgaon Packers And Movers is recognized as a business manager providing wide-ranging and differentiate service appearance as well as Relocation Shifting.Packers And Movers Gurgaon

  5. Excellent post! I must thank you for this informative read.Please Visit Our Webpage:
    In loading and unloading is done carefully by experienced workers. In addition, #PackersMovers unpacks the delivery at the target, very efficiently & with maximum care.

  6. Thanks for sharing useful information for us.I really enjoyed reading your blog, you have lots of great content.Please visit here:

  7. An excellent information provided thanks for all the informations i must say great efforts made by you.

  8. I really enjoyed reading your blog, you have lots of great content.Please visit here:
    Packers And Movers Patna Relocation, Main Office in Patna India, is a most important company relocation and home Shifting services association provided that relocation solutions to individuals and company houses.
    Packers And Movers Patna

  9. Thanks on your marvelous posting! I really enjoyed reading it, you’re a great author.Please visit here:http://packersmovershyderabadcity.in/
    Packers And Movers hyderabad
    based company provided that Movers And Packers Hyderabad Services for Office, Home, Local or domestic and commercial purposes.

  10. Great information on your site here. I love this post because we can get some useful information from your blog. I expect more post from you guys.
    Packers And Movers Bangalore

  11. Mother's Day is a celebration in regards to the mother of the family, and furthermore parenthood, maternal bonds, and the effect of mothers in the general population field. It is commended on various days in many parts of the world, most routinely in the seasons of February or normal of the week. It supplements near celebrations with respect to relatives, for instance, Father's Day and Siblings Day.

  12. Have Lovely and Beautiful Salwar Suit And Many More…
    We Have Some For You In Your Budget For more…
    Plz visit:- Ladies Suit

  13. The best collection of Happy Mothers Day 2017 Images, Photos, Pictures, Wallpapers, Mothers Day Quotes, Wishes, Messages, Greetings,
    Happy Mothers Day Poems & Sayings, Mothers Day Messages, SMS, Text Messages,
    fathers day images 2017
    fathers day wallpapers 2017
    fathers day pictures 2017
    fathers day cards 2017
    Happy fathers day images 2017
    fathers day quotes 2017
    fathers day wishes 2017
    fathers day messages 2017
    fathers day status 2017
    fathers day poems 2017
    Memorial Day wishes 2017
    Mothers Day WhatsApp Status & Facebook Status, DP Images,
    Mothers Day FB Profile Pics, FB Timeline Cover Photos etc.

  14. Our Collection is Best Designer Saree Lehenga, Gown ,Salwar Kameez etc...
    For more...
    Designer Kurti
    Wedding Dresss
    Punjabi Suit
    Diwali,Christmas,New year for Collection....
    Happy Diwali
    Merry Christmas
    Happy New Year

    Brindal Lehenga

  15. A movie is used for an entertainment of busy people.
    By seeing movie person experiences refreshment from their day to day life.
    For watching movie plz visit following site:-
    kingsman: the golden circle full movie download kickass torrent
    kingsman: the golden circle full movie the piratebay

  16. Get it when you most need it. Get connected to our instant point of sale support for QuickBooks and never stop selling. We provide installation, setup and technical troubleshooting for QuickBooks Point of sale. Call us for multi store setup and remote store configuration. Let us know if you are facing any technical issues with your Head Quaters.

    Quickbooks Support Phone Number

    QuickBooks Support Number

    QuickBooks Tech Support Phone Number

    QuickBooks Technical Support Phone Number

    QuickBooks Customer Service Phone Number

  17. Looking for Quickbooks Support ? Is your Quickbooks Working slow or Your Quickbooks Keeps Crashing? Dial QuickBooks Tech Support Phone Number 1888-396-0208. We Assign you the Technician who will start work on your problem and fix your issue and also give you the best offers related to your Quickbooks upgrade , payrol and many more. Call us now !


  18. That was a great read. I really like your writing style and how you explain certain things. I will be back to read more from you.We also provide Technical Support for QuickBooks Payroll , if you face any problem with your QuickBooks Payroll you can just click here QuickBooks Full Service Payroll Support. Or dial 1888-567-1159.

  19. QuickBooks Payroll Tech Support Number Toll Free Support The Independent Venture And People As They Can Monitors Execution Of The Organization, Installments, Consumptions And All Other Arrangements For Book-Keeping Just On A Tick.

  20. The QuickBooks Enterprise Support 1888-396-0208 Enterprise Technical Support Uses Advance Technology and Works Efficiently. That Makes It Possible To Complete The Work In A Specific Time Period. It Resolves Many Evolving Issues And Errors. All the Points Mentioned Above Makes It Different From Other Intuit Service Provider.

  21. Are you searching for solution for Merchants problems or fee misplace problems on QuickBooks? QuickBooks Support Phone Number.The Main Purpose And Usage Of QuickBooks Is To Offer System Suggested By Book-Keeping Specialist For Its Reliability And Vigorously Useful For Instant It Integrate With QuickBooks Software.
    Our Technical Experts are available 24x7 , just give us a call on 1888-567-1159.

  22. Quickbook Tech Support Phone Number 1888-396-0208 offers industry-specific solutions, notably for contractors, manufacturing and wholesale, nonprofits, and retailers. Quickbooks enterprise support stands unique in the market as it has got the best tool which can help us to fix our any kind of Quickbooks related issues. They help to resolve our problem quite instantly and easily. Pick your phone and dial our toll free number anytime, We are here to help you 24/7.

  23. Our group of QuickBooks Technicians at QuickBooks Support Phone Number 1888-396-0208 are Intuit Certified and profoundly experienced. Settling QuickBooks specialized issues is our everyday work. We can deal with the every one of the issues productively in an auspicious way. We additionally have a devoted information recuperation group for QuickBooks information assurance.

  24. We first understand your specific problem that yo are facing and provide you best solution, services, and maintenance for accounts. You only need to dial our toll-free POS Support 1800-291-2485.

  25. QuickBooks Payroll Phone Number is gainful Enterprise benefit for the organizations and associations having extensive workforce or representatives chipping away at a Enterprise premise. It can keep the reputation of all representatives compensation, stores, advantages, motivating forces, charges different conclusions or related exchanges identified with pay rates or wages of the considerable number of workers.

  26. QuickBooks® Support Phone Quickbooks 24x7 Tech support Number (Solve Technical Errors) QuickBooks® Technical Support Garner round the clock support from experienced QuickBooks professionals team through Quickbooks 24x7 Tech support Number 1800-291-2485 for swift resolution of QuickBooks problems.

  27. Permit of the product can't be checked. " QuickBooks Error 3371 : QuickBooks couldn't stack the permit information. This might be caused by absent or harmed records." License of the product can't be verified. QuickBooks clients can connect with us on the toll free number +1888-396-0208 which is accessible round the check for each client if there should be an occurrence of any product related mistake.

  28. To setup the email feature within QuickBooks When you choose Edit > Preferences > Send Forms > My Preferences, you may not see Outlook as an option for emailing from QuickBooks.to fix the issue call our Outlook Is Not An Option In QuickBooks Send Forms Preferences department and fix the issue by our technical expert team.

  29. QuickBooks enterprise arrangement is the propel specialized programming. This product is exceptionally valuable for Accounting reason and client effortlessly utilized it and influence your work to wind up simple. Quickbooks Enterprise Solutions Support 1888-557-6950.


  30. We also provide deep cleaning services for houses, villas, apartments and furnishings, and use of garden steam cleaners that clean and eliminate germs.
    You can see more of this link:
    شركة الاول للتنظيف و مكافحة الحشرات
    شركة مكافحة حشرات بالرياض شركة مكافحة حشرات بالرياض
    شركة رش مبيدات بالرياض شركة رش مبيدات بالرياض
    شركة رش مبيدات بالاحساء شركة رش مبيدات بالاحساء
    شركة تنظيف بالدمام

  31. Additionally, it keeps a precise record of exactly what financial decisions are created, the semantics and amounts which have to be monitored and reported. For this end, it's highly vital to understand why and ways to acquire quality QuickBooks Helpline 24 hour customer service whenever required.

  32. Packers and Movers Indore - Call 09303355424, Local Household Shifting in Indore, Domestic Home Relocation from Indore. International Home Relocation from Indore, Office Shifting within Indore, Car and Bike Transportation from Indore, Safe Packing and Moving Services,
    Packers and Movers Indore
    Packers and Movers Gurgaon
    Packers and Movers Kolkata
    Packers and Movers Mumbai
    Packers and Movers Bhopal
    Packers and Movers Delhi
    Packers and Movers Jaipur
    Packers and Movers Raipur
    Packers and Movers Pune
    Packers and Movers Ahmedabad

  33. Nice Article..We Provide Best Education. Please visit our Website: http://mewaruniversity.org/pages/default.aspx