Several jquery snippets help improve web development efficiency

Source: Internet
Author: User

Scroll smoothly to the top of the page

Here's one of the most common implementations of jquery: Click a link to scroll smoothly to the top of the page. There's nothing new to say, but almost every developer can use it.

$ ("a[href= ' #top ']"). Click (function() {     $ ("HTML, Body"). Animate ({scrolltop:0}, "slow");      returnfalse;   
Replace HTML tags

jquery can be very easy to implement HTML tag substitution, which will bring us more new possibilities.

$ (' Li '). ReplaceWith (function() {     return $ ("<div/>"). Append ($ ( This ). Contents ());   });
Detecting screen widths Now that mobile devices are almost more popular than traditional computers, it is important to detect the size of small screens. Fortunately, we can easily achieve this with jquery.
var responsive_viewport = $ (window). width ();    /*  *  /if (Responsive_viewport < 481) {       alert (' viewport is Smaller than 481px. ' );    /* */

Several jquery snippets help improve web development efficiency

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.