Common jQuery code sharing and jquery code

Source: Internet
Author: User

Common jQuery code sharing and jquery code

1. View browser Information

navigator.userAgent

Search for characters in browser Information

For example:

if (navigator.userAgent.toLowerCase().indexOf("htc") >= 0) {        $("#GuanKa .page_content").css("transform", "scale(0.92)");        $(".gaunka_pic").css("top", "-100px");        $(".ertongji_btn").css("top", "570px");      }

2. set parameters for the link, and then perform relevant operations based on the url parameters.

// The user has not uploaded the image that day $ (". js_uplaod_bnt "). click (function () {if ($ (this ). attr ("myid") = "1") {SiteFunc. ga ('select riding trease');} else if ($ (this ). attr ("myid") = "2") {SiteFunc. ga ('select sleep trease');} else if ($ (this ). attr ("myid") = "3") {SiteFunc. ga ('select kick papp');} else if ($ (this ). attr ("myid") = "4") {SiteFunc. ga ('select crawling trease');} else if ($ (this ). attr ("myid") = "5") {SiteFunc. ga ('select learning trease');} else if ($ (this ). attr ("myid") = "6") {SiteFunc. Ga ('select walking trease');} window. location. href = "Upload. aspx? BabyPostureID = "+ $ (this ). attr ("myid") ;}); // click the Icon to upload the image. func. getParamFromUrl ("BabyPostureID"); $ (". js_photo_icon_upimg img "). attr ("src", "images/result/photo_icon" + CurBabyPostureID + ". png ");

3. Mobile phone terminal long press trigger event

// When an element is pressed for 2 seconds, it jumps to a page var _ timeout = null. // You can also press the QR code to jump to the page $ (". js_LongPressToCard "). on ("touchstart", function () {window. clearTimeout (_ timeout); _ timeout = setTimeout (function () {window. location. href = "https://mbank.spdbccc.com.cn/creditcard/indexActivity.htm? Data = 000501 ";}, 2000) ;}); $ (". js_LongPressToCard "). on ("touchend", function () {window. clearTimeout (_ timeout );});

The above is all the content of this article. I hope you will like it.

Related Article

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.