如果包含某些模式,如何检查ID名称?

Arm*_*man 2 jquery

我正在使用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
Run Code Online (Sandbox Code Playgroud)

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

And*_*y E 5

使用属性包含选择器:

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