gpt4 book ai didi

jquery - 如何检查 id 名称是否包含某种模式?

转载 作者:行者123 更新时间:2023-12-01 02:49:21 24 4
gpt4 key购买 nike

我正在使用 jquery,并且循环如下:

$("span").each(function (index) {
var idname = $(this).attr('id');
$("#" + idname).click(function () {
window.location.href = "http://" + $(this).attr('id') + "lin.gw";
});

}); //end for click attachment to button

我想循环 id 包含 *raid* 的元素。它的语法是什么?

最佳答案

使用attribute-contains selector :

$("span[id*=raid]").click(function(){
window.location.href = "http://"+ this.id +"lin.gw";
});

关于jquery - 如何检查 id 名称是否包含某种模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4123406/

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