juqery获取两个字符之间的文字

    |     2016年5月12日   |   学习偶记   |     评论已关闭   |    2710

先上代码:

[html]</p><pre>$("input[name^=’pii’]").each(
function(){
if(parseInt($(this).val())&gt;0){
alert($(this).val());
alert($(this).prop("name").match(/\[([\s\S]*?)\]/)[1]));;
}
}
)
[/html]
这段代码是查询input name不等于pii的input,并且把intput的名字里[]内的内容显示出来。
知识点:
A、对象.prop(“name”) ,显示对象的名字,用attr也可以。
B、返回指定字符串中符合要求的字符串。方式 字符.match(/正则内容/)[1]

噢!评论已关闭。