zoukankan      html  css  js  c++  java
  • JQ动态获取URL参数

    $(function() {
            //从ulr中拿数据
            function GetQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            } //从url里边拿数据
            var n = GetQueryString("id");//拿出URL中id,当id等于多少的时候动态进行修改页面图片
            if (n == 0) {
                $(".menu .menu_nr img.mnImg2").attr("src", "images/qdImg2.png");
                $(".advantage .col-sm-5 img").attr("src", "images/s1_left.png");
            } else if (n == 1) {
                $(".menu .menu_nr img.mnImg2").attr("src", "images/qdImg2_2.png");
                $(".advantage .col-sm-5 img").attr("src", "images/s1_left2.png");
            } else if (n == 2) {
                $(".menu .menu_nr img.mnImg2").attr("src", "images/qdImg2_3.png");
                $(".advantage .col-sm-5 img").attr("src", "images/s1_left3.png");
            } else if (n == 3) {
                $(".menu .menu_nr img.mnImg2").attr("src", "images/qdImg2_4.png");
                $(".advantage .col-sm-5 img").attr("src", "images/s1_left4.png");
            } else if (n == 4) {
                $(".menu .menu_nr img.mnImg2").attr("src", "images/qdImg2_5.png");
                $(".advantage .col-sm-5 img").attr("src", "images/s1_left5.png");
            } else if (n == 5) {
                $(".menu .menu_nr img.mnImg2").attr("src", "images/qdImg2_6.png");
                $(".advantage .col-sm-5 img").attr("src", "images/s1_left6.png");
            } else if (n == 6) {
                $(".menu .menu_nr img.mnImg2").attr("src", "images/qdImg2_7.png");
                $(".advantage .col-sm-5 img").attr("src", "images/s1_left7.png");
            } else if (n == 7) {
                $(".menu .menu_nr img.mnImg2").attr("src", "images/qdImg2_8.png");
                $(".advantage .col-sm-5 img").attr("src", "images/s1_left8.png");
            } else {
                $(".menu .menu_nr img.mnImg2").attr("src", "images/qdImg2.png");
                $(".advantage .col-sm-5 img").attr("src", "images/s1_left.png");
            }
        })
  • 相关阅读:
    套路
    委托、事件 茴字有几种写法
    数学 矩阵
    webForm系列 前端框架快速引用
    图片引用
    【HTML】Advanced6:HTML5 Forms Pt. 1: Input Types
    【HTML】Advanced5:Accessible Forms
    【HTML】Advanced4:Accessible Links
    【HTML】Advanced3:Tables: Columns, Headers, and Footers
    【HTML】Advanced2:Conditional Comments
  • 原文地址:https://www.cnblogs.com/fkcqwq/p/11132860.html
Copyright © 2011-2022 走看看