截取字符串的问题
<a href= "http://www.discuz.net " target= "_blank "> Discuz </a>
这个是变量A的值
我想将href= " "里面的内容(http://www.discuz.net)给变量B
Discuz给变量C
这个怎么做啊?谢谢
------解决方案-------------------- <a href= "http://www.discuz.net " target= "_blank " id= "lk "> Discuz </a>
将链接加个id
脚本如下:
var link=document.getElementById(lk);
link.href=B;
C=link.innerText;
------解决方案-------------------- <script>
var str= ' <a href= "http://www.discuz.net " target= "_blank "> Discuz </a> ';
str.match(/href\s*=\s*\ "(.*?)\ "\s+/ig);
alert(RegExp.$1)
</script>
------解决方案-------------------- <script>
var str= ' <a href= "http://www.discuz.net " target= "_blank "> Discuz </a> ';
str.match(/ <a\s*href\s*=\s*\ "(.*?)\ "\s+.*> (.*?) <\/a> /ig);
var b=RegExp.$1 ;
var c=RegExp.$2 ;
alert(b);
alert(c);
</script>