首页 \ 问答 \ JavaScript在行走JSON树时更改路径[重复](JavaScript change the path when walking a JSON tree [duplicate])

JavaScript在行走JSON树时更改路径[重复](JavaScript change the path when walking a JSON tree [duplicate])

这个问题在这里已有答案:

目前,正如您可以从这个小提琴中看到的那样,我将JSON存储为变量:

const tree = { ...
}

然后,JS遍历整个树,搜索“201603”下的所有结果:

const Chart201603 = walk(tree, '201603');

最后,脚本然后仅搜索要显示的“浓度”节点:

const Chart201603_Concentration = Chart201603.map(entry => {
        return entry.Concentration;
      });

然后在'201603'和'Concentration'下的整个树中找到的数字数组打印到我的HTML中的span以及数组的总和:

排列

我还可以通过更改此行来指定JS中我希望JS在哪里查找此信息:

const Chart201603 = walk(tree, '201603');

对于这样的事情:

const Chart201603 = walk(tree.BILL.Municipal, '201603');

现在,由于它跳过了一些节点,因此返回的结果更少:

新数组

然而,我想做的,而不是像这样硬编码到JS的所需路径,是因为它等于文本区域或跨度等的值。

这样的东西。

现在有一个设置值的跨度,如下所示:

<span id="value">BILL.Municipal</span>

我创建了一个跨度值的变量:

const newPath = document.getElementById('value').innerHTML;

但是现在当我设置这样的路径时:

const Chart201603 = walk(tree.newPath, '201603');

它不会返回任何结果。

任何人都可以帮助解决这个问题吗? 并建议我如何使这种方法工作?

这里是代码,你不想用JSFiddle测试:

const walk = (root, filter) => {
  const result = [];
  const follow = (root) => {
    if (root instanceof Array) {
      root.forEach(elem => {
        follow(elem);
      });
    } else if (root instanceof Object) {
      Object.keys(root).forEach(elem => {
        if (elem === filter) {
          result.push(root[elem]);
        } else {
          follow(root[elem]);
        }
      });
    }
  };
  follow(root);
  return result;
};

const tree = {
"BILL" : {
	"Municipal" : {
    "CAD" : {
      "Short" : {
        "Low" : {
          "High" : {
            "N" : {
              "CANADA" : {
                "IssueName00085" : {
                  "CA6832Z57Z70" : {
                    "201603" : {
                    	"Concentration" : 2,
                      "ConcentrationTier1" : 2,
                      "ConcentrationTier2" : 0,
                      "LargestTicket" : 0,
                      "Maturity" : 201708,
                      "Outstanding" : 140,
                      "SmallestTicket" : 0,
                      "Turnover" : 0,
                      "TurnoverTeir2" : 0,
                      "TurnoverTier1" : 0
                    },
                    "201604" : {
                      "Concentration" : 6,
                      "ConcentrationTier1" : 3,
                      "ConcentrationTier2" : 3,
                      "LargestTicket" : 0,
                      "Maturity" : 201708,
                      "Outstanding" : 140,
                      "SmallestTicket" : 0,
                      "Turnover" : 0,
                      "TurnoverTeir2" : 0,
                      "TurnoverTier1" : 0
                    }
                   }
                  }
                 },
                 "USA" : {
                 	 "IssueName00953" : {
                     "USA688I57Z70" : {
                        "201603" : {
                          "Concentration" : 4,
                          "ConcentrationTier1" : 2,
                          "ConcentrationTier2" : 2,
                          "LargestTicket" : 0,
                          "Maturity" : 201708,
                          "Outstanding" : 40,
                          "SmallestTicket" : 0,
                          "Turnover" : 0,
                          "TurnoverTeir2" : 0,
                          "TurnoverTier1" : 0
                        },
                        "201604" : {
                          "Concentration" : 9,
                          "ConcentrationTier1" : 7,
                          "ConcentrationTier2" : 2,
                          "LargestTicket" : 0,
                          "Maturity" : 201708,
                          "Outstanding" : 140,
                          "SmallestTicket" : 0,
                          "Turnover" : 0,
                          "TurnoverTeir2" : 0,
                          "TurnoverTier1" : 0
                    }
                   }
                  }
                 }
                }
               }
              }
             }
            }
           },
           	"Sovereign" : {
    "USD" : {
      "Short" : {
        "High" : {
          "High" : {
            "N" : {
              "MEXICO" : {
                "IssueName00385" : {
                  "ME6832Z57Z70" : {
                    "201603" : {
                    	"Concentration" : 9,
                      "ConcentrationTier1" : 2,
                      "ConcentrationTier2" : 7,
                      "LargestTicket" : 0,
                      "Maturity" : 201708,
                      "Outstanding" : 140,
                      "SmallestTicket" : 0,
                      "Turnover" : 0,
                      "TurnoverTeir2" : 0,
                      "TurnoverTier1" : 0
                    },
                    "201604" : {
                      "Concentration" : 16,
                      "ConcentrationTier1" : 3,
                      "ConcentrationTier2" : 13,
                      "LargestTicket" : 0,
                      "Maturity" : 201708,
                      "Outstanding" : 140,
                      "SmallestTicket" : 0,
                      "Turnover" : 0,
                      "TurnoverTeir2" : 0,
                      "TurnoverTier1" : 0
                    }
                   }
                  }
                 },
                 "USA" : {
                 	 "IssueName00953" : {
                     "USA688I57Z70" : {
                        "201603" : {
                          "Concentration" : 4,
                          "ConcentrationTier1" : 2,
                          "ConcentrationTier2" : 2,
                          "LargestTicket" : 0,
                          "Maturity" : 201708,
                          "Outstanding" : 40,
                          "SmallestTicket" : 0,
                          "Turnover" : 0,
                          "TurnoverTeir2" : 0,
                          "TurnoverTier1" : 0
                        },
                        "201604" : {
                          "Concentration" : 9,
                          "ConcentrationTier1" : 7,
                          "ConcentrationTier2" : 2,
                          "LargestTicket" : 0,
                          "Maturity" : 201708,
                          "Outstanding" : 140,
                          "SmallestTicket" : 0,
                          "Turnover" : 0,
                          "TurnoverTeir2" : 0,
                          "TurnoverTier1" : 0
                    }
                   }
                  }
                 }
                }
               }
              }
             }
            }
           }
					}
				 }
         
         const newPath = document.getElementById('value').innerHTML;
         
         console.log(newPath)
         
         const Chart201603 = walk(tree.newPath, '201603');

          const Chart201603_Concentration = Chart201603.map(entry => {
            return entry.Concentration;
          });

          document.getElementById("Array201603Concentration").innerHTML = Chart201603_Concentration.join(' ');

          var ConcentrationSum = Chart201603_Concentration.reduce((total, num) => {
            return total + num;
          }, 0);
          
           document.getElementById("Array201603ConcentrationSum").innerHTML = ConcentrationSum;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="value">BILL.Municipal</span>

<p>Array: <span id="Array201603Concentration"></span></p>

<p>Array Sum: <span id="Array201603ConcentrationSum"></span></p>


This question already has an answer here:

Currently, as you can see from this fiddle, I have a JSON stored as the variable:

const tree = { ...
}

The JS then walks the entire tree searching for all results under '201603':

const Chart201603 = walk(tree, '201603');

Finally, the script then searches for only 'Concentration' nodes to be displayed:

const Chart201603_Concentration = Chart201603.map(entry => {
        return entry.Concentration;
      });

The array of numbers found in the entire tree under '201603' and 'Concentration' is then printed to a span in my HTML as well as the sum of the array:

Array

I can also specify where in the tree I want the JS to look for this information by changing this line:

const Chart201603 = walk(tree, '201603');

To something like this:

const Chart201603 = walk(tree.BILL.Municipal, '201603');

This now returns fewer results as it has skipped out some nodes:

New Array

What I want to do, however, rather than hard code the desired path into the JS like this, is for it to equal the value of a text area or span etc.

Something like this.

Now there is a span with the value set like so:

<span id="value">BILL.Municipal</span>

And i've created a variable of the spans value:

const newPath = document.getElementById('value').innerHTML;

But now when I set the path like so:

const Chart201603 = walk(tree.newPath, '201603');

It does not return any results.

Can anybody help with this issue? And advise how I can get this method working?

Here is the code too incase you would rather not test with JSFiddle:

const walk = (root, filter) => {
  const result = [];
  const follow = (root) => {
    if (root instanceof Array) {
      root.forEach(elem => {
        follow(elem);
      });
    } else if (root instanceof Object) {
      Object.keys(root).forEach(elem => {
        if (elem === filter) {
          result.push(root[elem]);
        } else {
          follow(root[elem]);
        }
      });
    }
  };
  follow(root);
  return result;
};

const tree = {
"BILL" : {
	"Municipal" : {
    "CAD" : {
      "Short" : {
        "Low" : {
          "High" : {
            "N" : {
              "CANADA" : {
                "IssueName00085" : {
                  "CA6832Z57Z70" : {
                    "201603" : {
                    	"Concentration" : 2,
                      "ConcentrationTier1" : 2,
                      "ConcentrationTier2" : 0,
                      "LargestTicket" : 0,
                      "Maturity" : 201708,
                      "Outstanding" : 140,
                      "SmallestTicket" : 0,
                      "Turnover" : 0,
                      "TurnoverTeir2" : 0,
                      "TurnoverTier1" : 0
                    },
                    "201604" : {
                      "Concentration" : 6,
                      "ConcentrationTier1" : 3,
                      "ConcentrationTier2" : 3,
                      "LargestTicket" : 0,
                      "Maturity" : 201708,
                      "Outstanding" : 140,
                      "SmallestTicket" : 0,
                      "Turnover" : 0,
                      "TurnoverTeir2" : 0,
                      "TurnoverTier1" : 0
                    }
                   }
                  }
                 },
                 "USA" : {
                 	 "IssueName00953" : {
                     "USA688I57Z70" : {
                        "201603" : {
                          "Concentration" : 4,
                          "ConcentrationTier1" : 2,
                          "ConcentrationTier2" : 2,
                          "LargestTicket" : 0,
                          "Maturity" : 201708,
                          "Outstanding" : 40,
                          "SmallestTicket" : 0,
                          "Turnover" : 0,
                          "TurnoverTeir2" : 0,
                          "TurnoverTier1" : 0
                        },
                        "201604" : {
                          "Concentration" : 9,
                          "ConcentrationTier1" : 7,
                          "ConcentrationTier2" : 2,
                          "LargestTicket" : 0,
                          "Maturity" : 201708,
                          "Outstanding" : 140,
                          "SmallestTicket" : 0,
                          "Turnover" : 0,
                          "TurnoverTeir2" : 0,
                          "TurnoverTier1" : 0
                    }
                   }
                  }
                 }
                }
               }
              }
             }
            }
           },
           	"Sovereign" : {
    "USD" : {
      "Short" : {
        "High" : {
          "High" : {
            "N" : {
              "MEXICO" : {
                "IssueName00385" : {
                  "ME6832Z57Z70" : {
                    "201603" : {
                    	"Concentration" : 9,
                      "ConcentrationTier1" : 2,
                      "ConcentrationTier2" : 7,
                      "LargestTicket" : 0,
                      "Maturity" : 201708,
                      "Outstanding" : 140,
                      "SmallestTicket" : 0,
                      "Turnover" : 0,
                      "TurnoverTeir2" : 0,
                      "TurnoverTier1" : 0
                    },
                    "201604" : {
                      "Concentration" : 16,
                      "ConcentrationTier1" : 3,
                      "ConcentrationTier2" : 13,
                      "LargestTicket" : 0,
                      "Maturity" : 201708,
                      "Outstanding" : 140,
                      "SmallestTicket" : 0,
                      "Turnover" : 0,
                      "TurnoverTeir2" : 0,
                      "TurnoverTier1" : 0
                    }
                   }
                  }
                 },
                 "USA" : {
                 	 "IssueName00953" : {
                     "USA688I57Z70" : {
                        "201603" : {
                          "Concentration" : 4,
                          "ConcentrationTier1" : 2,
                          "ConcentrationTier2" : 2,
                          "LargestTicket" : 0,
                          "Maturity" : 201708,
                          "Outstanding" : 40,
                          "SmallestTicket" : 0,
                          "Turnover" : 0,
                          "TurnoverTeir2" : 0,
                          "TurnoverTier1" : 0
                        },
                        "201604" : {
                          "Concentration" : 9,
                          "ConcentrationTier1" : 7,
                          "ConcentrationTier2" : 2,
                          "LargestTicket" : 0,
                          "Maturity" : 201708,
                          "Outstanding" : 140,
                          "SmallestTicket" : 0,
                          "Turnover" : 0,
                          "TurnoverTeir2" : 0,
                          "TurnoverTier1" : 0
                    }
                   }
                  }
                 }
                }
               }
              }
             }
            }
           }
					}
				 }
         
         const newPath = document.getElementById('value').innerHTML;
         
         console.log(newPath)
         
         const Chart201603 = walk(tree.newPath, '201603');

          const Chart201603_Concentration = Chart201603.map(entry => {
            return entry.Concentration;
          });

          document.getElementById("Array201603Concentration").innerHTML = Chart201603_Concentration.join(' ');

          var ConcentrationSum = Chart201603_Concentration.reduce((total, num) => {
            return total + num;
          }, 0);
          
           document.getElementById("Array201603ConcentrationSum").innerHTML = ConcentrationSum;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="value">BILL.Municipal</span>

<p>Array: <span id="Array201603Concentration"></span></p>

<p>Array Sum: <span id="Array201603ConcentrationSum"></span></p>


原文:https://stackoverflow.com/questions/45863430
更新时间:2023-09-20 18:09

最满意答案

您需要使用所有视图状态POST到相同的URL,然后将__EVENTARGUMENT帖子值更改为Page $ 1,Page $ 2,Page $ 3等

像这样的东西

    //Create request to URL.
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.roads.maryland.gov/pages/cic.aspx?PageId=857&Type=tab");

    //Set request headers.
    request.KeepAlive = true;
    request.Headers.Add("Origin", @"http://www.roads.maryland.gov");
    request.Headers.Add("X-MicrosoftAjax", "Delta=true");
    request.UserAgent = "Mozilla/1.0";
    request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
    request.Accept = "*/*";
    request.Headers.Set(HttpRequestHeader.AcceptLanguage, "en-GB,en;q=0.8,en-US;q=0.6");

    //Set request method
    request.Method = "POST";

    // Disable 'Expect: 100-continue' behavior. More info: http://haacked.com/archive/2004/05/15/http-web-request-expect-100-continue.aspx
    request.ServicePoint.Expect100Continue = false;

    //Set request body.
    string body = "__EVENTARGUMENT=Page%24";
    body += pageNumber.ToString();
    body += @"&ctl00%24PlaceHolderMain%24ScriptManager1=ctl00%24PlaceHolderMain%24CICContract1%24displayPanel1%7Cctl00%24PlaceHolderMain%24CICContract1%24gvSSP&MSO_PageHashCode=687&MSOWebPartPage_PostbackSource=&MSOTlPn_SelectedWpId=&MSOTlPn_View=0&MSOTlPn_ShowSettings=False&MSOGallery_SelectedLibrary=&MSOGallery_FilterString=&MSOTlPn_Button=none&__REQUESTDIGEST=0x8DBC9CD602B61A910B12C83C03A47B6755DE07797515E34AEA8EE0BDC93813FC6A208251090430008C51E50BF4A3D0EBEAF4A9F2CC60072EC4B6B5FED3F48D31%2C20%20Nov%202014%2017%3A15%3A59%20-0000&MSOSPWebPartManager_DisplayModeName=Browse&MSOWebPartPage_Shared=&MSOLayout_LayoutChanges=&MSOLayout_InDesignMode=&MSOSPWebPartManager_OldDisplayModeName=Browse&MSOSPWebPartManager_StartWebPartEditingName=false&ctl00%24PlaceHolderSearchArea%24q=Search&ctl00%24PlaceHolderMain%24CICContract1%24ddlPulldown=tab&__EVENTTARGET=ctl00%24PlaceHolderMain%24CICContract1%24gvSSP&__LASTFOCUS=&__VIEWSTATE=%2F 

...massive viewstate...

    %3D&__VIEWSTATEGENERATOR=E6DD55AA&__EVENTVALIDATION=%2FwEWKwK7ur20CQKpuunwCgLbzK2CBQKBio7OBALDpsvcBQK6mIPlBQLa0ZnPCgLmidHRCQKu%2FbCaDQKvg%2BHxDwKl%2FYSaDQK87ov7BQKV8JfxAQKdo6DlBgLSppvcBQLFutGoAwK3suC5CgK3spS5CgK3sui5CgK3svC5CgK3suS5CgK3svi5CgK3ssy5CgK3ssC5CgLZuKSJCwKykYb0DgKrq%2FH8DAK3zM7sDALA%2BfaWBAKYyYezCwK3suC5CgK3spS5CgK3sui5CgK3svC5CgK3suS5CgK3svi5CgK3ssy5CgK3ssC5CgLZuKSJCwKykYb0DgKrq%2FH8DALl54b0BgK%2FjseDBA0f8JbX2FIE%2F7%2FP1ojwVriOGXif&__ASYNCPOST=true&";

    byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
    request.ContentLength = postBytes.Length;
    Stream stream = request.GetRequestStream();
    stream.Write(postBytes, 0, postBytes.Length);
    stream.Close();

    //Get response to request.
    response = (HttpWebResponse)request.GetResponse();

You'll need to POST to the same URL with all the viewstate you can then vary the __EVENTARGUMENT post value to Page$1, Page$2, Page$3, etc

Something like this

    //Create request to URL.
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.roads.maryland.gov/pages/cic.aspx?PageId=857&Type=tab");

    //Set request headers.
    request.KeepAlive = true;
    request.Headers.Add("Origin", @"http://www.roads.maryland.gov");
    request.Headers.Add("X-MicrosoftAjax", "Delta=true");
    request.UserAgent = "Mozilla/1.0";
    request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
    request.Accept = "*/*";
    request.Headers.Set(HttpRequestHeader.AcceptLanguage, "en-GB,en;q=0.8,en-US;q=0.6");

    //Set request method
    request.Method = "POST";

    // Disable 'Expect: 100-continue' behavior. More info: http://haacked.com/archive/2004/05/15/http-web-request-expect-100-continue.aspx
    request.ServicePoint.Expect100Continue = false;

    //Set request body.
    string body = "__EVENTARGUMENT=Page%24";
    body += pageNumber.ToString();
    body += @"&ctl00%24PlaceHolderMain%24ScriptManager1=ctl00%24PlaceHolderMain%24CICContract1%24displayPanel1%7Cctl00%24PlaceHolderMain%24CICContract1%24gvSSP&MSO_PageHashCode=687&MSOWebPartPage_PostbackSource=&MSOTlPn_SelectedWpId=&MSOTlPn_View=0&MSOTlPn_ShowSettings=False&MSOGallery_SelectedLibrary=&MSOGallery_FilterString=&MSOTlPn_Button=none&__REQUESTDIGEST=0x8DBC9CD602B61A910B12C83C03A47B6755DE07797515E34AEA8EE0BDC93813FC6A208251090430008C51E50BF4A3D0EBEAF4A9F2CC60072EC4B6B5FED3F48D31%2C20%20Nov%202014%2017%3A15%3A59%20-0000&MSOSPWebPartManager_DisplayModeName=Browse&MSOWebPartPage_Shared=&MSOLayout_LayoutChanges=&MSOLayout_InDesignMode=&MSOSPWebPartManager_OldDisplayModeName=Browse&MSOSPWebPartManager_StartWebPartEditingName=false&ctl00%24PlaceHolderSearchArea%24q=Search&ctl00%24PlaceHolderMain%24CICContract1%24ddlPulldown=tab&__EVENTTARGET=ctl00%24PlaceHolderMain%24CICContract1%24gvSSP&__LASTFOCUS=&__VIEWSTATE=%2F 

...massive viewstate...

    %3D&__VIEWSTATEGENERATOR=E6DD55AA&__EVENTVALIDATION=%2FwEWKwK7ur20CQKpuunwCgLbzK2CBQKBio7OBALDpsvcBQK6mIPlBQLa0ZnPCgLmidHRCQKu%2FbCaDQKvg%2BHxDwKl%2FYSaDQK87ov7BQKV8JfxAQKdo6DlBgLSppvcBQLFutGoAwK3suC5CgK3spS5CgK3sui5CgK3svC5CgK3suS5CgK3svi5CgK3ssy5CgK3ssC5CgLZuKSJCwKykYb0DgKrq%2FH8DAK3zM7sDALA%2BfaWBAKYyYezCwK3suC5CgK3spS5CgK3sui5CgK3svC5CgK3suS5CgK3svi5CgK3ssy5CgK3ssC5CgLZuKSJCwKykYb0DgKrq%2FH8DALl54b0BgK%2FjseDBA0f8JbX2FIE%2F7%2FP1ojwVriOGXif&__ASYNCPOST=true&";

    byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
    request.ContentLength = postBytes.Length;
    Stream stream = request.GetRequestStream();
    stream.Write(postBytes, 0, postBytes.Length);
    stream.Close();

    //Get response to request.
    response = (HttpWebResponse)request.GetResponse();

相关问答

更多
  • 这是一个使用jQuery的非常基本的例子 关键在于: function togglePage(page) { for (var i = 1 ; i < pageSize + 1; i++) { $("#product-" + ((page * pageSize) + i)).toggle(); } } 您可以使用更复杂的选择器以更少的代码执行此操作,但我一直保持非jQuery用户能够阅读的简单。 基本上,我正在计算每次根据页面大小显示的项目。 为简单起见,我把它 ...
  • 您可以尝试构建SPA(单页应用程序)。 您将拥有一个索引html文件,该文件使用其他html文件作为模板。 例如,您有一个div主容器,其内容在单击链接时将替换为users.html / cars.html / bills.html。 路由可帮助您在不刷新页面的情况下完成此操作。 它还支持历史。 查找依赖注入,以便您了解如何只下载您依赖的js文件。 如果您不使用路由,并且您只更改页面内容,则会丢失历史记录,这是一个非常巧妙的事情。 带路由和模板的SPA 使用Sammy.js进行路由 例子: < ...
  • 我最终打开了一个新选项卡并在该选项卡中获取该页面。 然后使用内容脚本,我分析页面数据。 当然,这是一个问题,用户将看到新打开的选项卡。 但它对用户也是透明的。 如果您使用Jetpack在Firefox上开发扩展,则可以使用page-worker,它是一个不可见的页面并提供对DOM的访问。 I ended up opening a new tab and fetching the page in that tab. Then using content script, I analyze the page d ...
  • 制作一些发生的事情的方法,并将此方法放在每个页面上链接的公共js文件上,并在每个页面$(document).ready(fucntion(){})事件上调用该方法。 function anyMethodName(){ //Do your required stuff here. } 并在$(document).ready(fucntion(){})上调用它,如: $(document).ready(fucntion(){ anyMethodName(); }) Make a method of ...
  • 您需要使用所有视图状态POST到相同的URL,然后将__EVENTARGUMENT帖子值更改为Page $ 1,Page $ 2,Page $ 3等 像这样的东西 //Create request to URL. HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.roads.maryland.gov/pages/cic.aspx?PageId=857&Type=tab"); //Set re ...
  • 这里有一些伪代码,如果我正确理解你需要什么:有很多方法可以做到这一点,我没有太多的事情要做,所以这里只是一个例子。
  • 除非你创建一些,否则在asp.net中使用母版页时没有javascript问题。 ;) 在编写javascript时,您应该看到在处理页面时生成的最终html并处理该html而不是考虑母版页或内容页面。 您可以将常用的javascript函数放在母版页中,以便可以在所有内容页面中访问它。 另外,我建议将所有javascript放在外部文件中,并将其包含在母版页中。 这是一个很好的做法。 如果您遇到一些问题,可以发布具体问题,我们可以尝试解决它们。 祝一切顺利... There are no javascri ...
  • 你必须把你的代码重组一点点。 不建议在div上使用data-role="button" 。 在button标签上或button上使用它。 您必须在goToMenu函数中放置动态生成页面的所有代码。 添加它,然后使用changePage 。 不建议使用onclick 。 使用jQuery方式的事件委托。 这是标记:
  • 您可以尝试通过转义字符(symbolsw)并查看aspx是否仍然可以识别它们(预期它应该将它们识别为纯文本)。 "\<\%\= Number(value).toFixed(0).replace('.', ',') + ' %'\%\>" 或者,您可以将JavaScript代码放在单独的文件中 You can try by escaping the characters (symbolsw) and see if aspx still recognizes them (the expected is it ...
  • 增加要包含的值的常用技巧是使用%运算符。 对于递减,您只需强制它并检查负值: var mediaSizes = ['xs','md','lg']; var media = 0; $scope.mediaDisplay = mediaSizes[media]; var changeMedia = function(direction) { if (direction === 'up') { media = ++media % mediaSizes.lengt ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)