jquery模糊匹配

来源:互联网 发布:看刀路软件 编辑:程序博客网 时间:2024/05/01 09:52
 

[属性名称] 匹配包含给定属性的元素
[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());

原创粉丝点击