2
我有兩個字符串,check_url
和curr_url
匹配兩個字符串中的jQuery
<script>
var check_url='http://localhost/project/show/{dynamic content}';
var locationHref = $(location).attr('href');//current url
</script>
在此我需要匹配兩個字符串。 我嘗試下面的代碼
var urlslugRegex = '/^[a-z0-9-]+$/';
if(locationHref == 'http://localhost/project/show/'+(urlslugRegex)){
alert("if");
}else{
alert("else");
}
你要檢查,如果一個字符串其他字符串相匹配? – ahervin
是的......但我不會得到這個頁面中的動態內容......只有正則表達式我可以使用 – sbkkoovery
而不是你可以使用'window.location.href;' – Jai