js正则备忘

<script>
function lang_mouseover(obj){
var path = String(window.location);
var re = /l=/;
if(!re.test(path)){
obj.href=path+'&l='+obj.id;
}else{
obj.href=path.replace(/l=\w{2}(-[a-z]{2})?/g,'l='+obj.id);
}
}

</script>

<a href="#" class="lang" id="zh-cn" onmouseover="lang_mouseover(this)">中文</a> | <a href="#" class="lang" id="en" onmouseover="lang_mouseover(this)">English</a>

你可能感兴趣的:(js)