在我的页面中,我有一些以这种方式编写的输入按钮:
<input type="button" value="" idtag="" style="color:rgb(51, 156, 203); background-color:white; border:0px; padding:0px;">
我可以使用正则表达式获取值和idtag的值吗?并且在替换方法之后,替换字符串上的结果?
text = text.replace(/(<input type="button" value="(.+)" idtag="(.+)" style="color:rgb(51, 156, 203); background-color:white; border:0px; padding:0px;"> )/gi, function($0,$1,$2){return $3+"-"+$4;});
谢谢
答案 0 :(得分:1)
它们是DOM对象的属性,因此您可以像这样检索它们:
var button = ...;
var idtag = button['idtag'];
var value = button['value'];