jquery模糊匹配

<select class="1234FFFF" />
<select class="5t3rFFFF" />
<select class="d3d3FFFF" />
<select class="d3d3SSSS" />

$("select[class]").each(function(){
  var class = $(this).attr("class");
  if(/FFFF$/.test(class)){
    //这里放要处理的代码
  }
});
******************************************************************************************************************************************


[属性名称] 匹配包含给定属性的元素
[att=value] 匹配包含给定属性的元素 (大小写区分)
[att*=value] 模糊匹配
[att!=value] 不能是这个值
[att$=value] 结尾是这个值
[att^=value] 开头是这个值
[att1][att2][att3]... 匹配多个属性条件中的一个

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("div:contains('John')").css("text-decoration", "underline");
});
</script>
</head>
<body>
<div>John Resig</div>
<div>George Martin</div>
<div>Malcom John Sinclair</div>
<div>J. Ohn
</body>
</html>

<script language="javascript">
$(function(){
alert($('#dialog[title*=Basic]').attr('class'));

answer:text edit-server-1 ui-draggable

alert($('#dialog[title*=B]').attr('class').match(/edit\-server\-[0-9]+/));

answer:edit-server-1

alert($('#dialog[title*=B]').attr('class').match(/edit\-server\-[0-9]+/).match(/\d+/g));

answer:1

})
</script>
</head>

<body>
<div id="dialog" title="Basic dialog" class="text edit-server-1 ui-draggable">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>

</body>
</html>

$("input[class*=order-<?php echo $_productColor['sizes'][$i]['size'];?>]").val($(this).val());
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值