gpt4 book ai didi

javascript - 从 url 中获取数字

转载 作者:数据小太阳 更新时间:2023-10-29 05:01:08 25 4
gpt4 key购买 nike

<分区>

我需要从 url 中获取 id。所以如果 url 是这样的:http://localhost:17241/Chart.aspx?id=11

我应该得到数字 11 作为输出。但是每个网站上都有不同的ID。之后我将用它设置 z-index。

我已经尝试写点东西了

$.urlParam = function (name) {
var patt1 = new RegExp('[^17241]').exec(window.location.href);
return result[1] || 0;
document.getElementById("link").innerHTML = result;}

但这根本行不通。有谁知道该怎么做吗?

所以现在它应该改变 z-index:

var url = window.location.href;
var params = url.split('?');
var id = params[1].split('=')[1]; //params[1] will contain everything after ?
console.log(id);
if(id == 11)
{
$(“#one”).each(function() {
$(this).css(“z-index“, 0);
});

}

else if(id == 31)
{
$(“#four”).each(function() {
$(this).css(“z-index“, 0);
});
}

它应该改变 div 的 z-index

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<div class="contentwidth" id="chartdiv">
<asp:Label ID="lblStatus" runat="server"></asp:Label>
<div id="one" style="position: absolute; top: 0; left: 0; height: 100%; width: 100%;">
<asp:Literal ID="ltrRenderChart" runat="server"></asp:Literal>
</div>
<div id="two" style="position: absolute; top: 0; left: 50%; height: 100%; width: 100%; z-index:-1">
<asp:Literal ID="ltrRenderChart2" runat="server"></asp:Literal>
</div>
<div id="three" style="position: absolute; top: 50%; left: 0; height: 100%; width: 100%; z-index:-1">
<asp:Literal ID="ltrRenderChart3" runat="server"></asp:Literal>
</div>
<div id="four" style="position: absolute; top: 50%; left: 50%; height: 100%; width: 100%; z-index:-1 ">
<asp:Literal ID="ltrRenderChart4" runat="server"></asp:Literal>
</div>
</div>

谢谢

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com