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