jquery获取以开头的id值
jquery获取以开头的id值示例代码如下:
<style type="text/css">
#f-one {
width: 100px;
height:100px;
background-color: red;
}
#f-two {
width: 100px;
height:100px;
background-color: blue;
}
#f-three {
width: 100px;
height:100px;
background-color: yellow;
}
</style>
<div id="f-one">
</div>
<div id="f-two">
</div>
<div id="f-three">
</div>
<input type="button" onclick="finddiv()" value="寻找div">
<script type="text/javascript">
function finddiv(){
$("div[id^='f']").css('display','none');
}
</script>
效果如图: