Wildcard search of an elements id using jQuery

前端 未结 3 2182
Happy的楠姐
Happy的楠姐 2021-01-07 04:54

I have the following:

if($(\"div[id*=\'*test-*-0-value\']\").length > 0){
    // do stuff
}

Unfortunatly the wild card *test-*-0-v

3条回答
  •  自闭症患者
    2021-01-07 05:19

    use james padolsey jquery's regex selector , and apply it to your example like :

    if($("div:regex(id, *test-*-0-value").length > 0) {
    
    }
    

提交回复
热议问题