Several useful JQuery techniques and JQuery useful techniques
JQuery code
/* Open the link in the new window: JQuery filter attr * disable the mouse to pop up the right-click menu: DOM contextmenu * back to the top of the page: DOM scrollTo * dynamic change Css style sheet: JQuery filter Element Attribute * adjust the page font size: Css html.css parseFloat * // determine whether DOM loading is complete $ (document ). the href attribute of ready (function () {/* link starts with http and opens the link in the new window * // ^ filter. properties: start with a specific string $ ("a [href ^ = 'HTTP ']"). attr ("target", "_ blank");/* Right-click prohibited * // The contextmenu of DOM is the right-click menu $ (document ). bind ("contextmenu", function (e) {alert (( "No right-clicking! "); // Do not run down, that is, the right-click menu cannot return false ;}); /* return to the top of the page * // id = "top" element's click Event trigger $ ('# top '). click (function () {// return to the top of the page $ (document ). scrollTo (0,500 );}); /* dynamically change the css style table of the page * // use the href value of the page link to replace the href attribute value of the link tag $ ("a.css Swap "). click (function () {$ ("link [rel = stylesheet]"). attr ("href", $ (this ). attr ("rel");});/* enlarge, zoom in, or restore the page font size * // obtain the font size, the font-size var originalFontSize = $ ("html" ).css ("font-size") is defined under the html Tag; // restore the default font size $ (". resetFont "). click (function () {$ ("html" ).css ("font-size", originalFontSize); // JavaScript does not run return false;}); // increase the font, the class of an element is defined as increaseFont $ (". increaseFont "). click (function () {// get the current font size suffix px, pt, pc var currentFontSize =$ ("html" ).css ("font-size "); // get the current font size. Convert parseFloat () to the float type to remove the suffix var currentFontSizeNumber = parseFloat (currentFontSize); // the newly defined font size var newFontSize = currentFontSizeNumber * 1.1; // rewrite the style sheet $ ("html" ).css ("font-size", newFontSize); // do not run return false in JavaScript;}); // reduce the font, the class of an element is defined as decreaseFont $ (". decreaseFont "). click (function () {// get the current font size suffix px, pt, pc var currentFontSize =$ ("html" ).css ("font-size "); // get the current font size. Convert parseFloat () to the float type to remove the suffix var currentFontSizeNumber = parseFloat (currentFontSize); // redefine the font size var newFontSize = currentFontSizeNumber * 0.9; // rewrite the style sheet $ ("html" ).css ("font-size", newFontSize); // do not run return false ;});});
Html code:
<! DOCTYPE html> <meta charset = "UTF-8"/>