jQuery: If this HREF contains

前端 未结 6 1825
南笙
南笙 2021-01-30 20:51

Why can\'t I get this to work??

$(\"a\").each(function() {
    if ($(this[href$=\"?\"]).length()) {
        alert(\"Contains questionmark\");
    }
});
         


        
6条回答
  •  春和景丽
    2021-01-30 21:06

    $("a").each(function() {
        if (this.href.indexOf('?') != -1) {
            alert("Contains questionmark");
        }
    });
    

提交回复
热议问题