jQuery返回ID以某个字符串开头的元素 [英] jQuery Return elements where ID begins with a certain string
本文介绍了jQuery返回ID以某个字符串开头的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有很多< span>
标签,例如< span id ='val_Title'>< / span> < span id ='val_Name'>< / span>
我想返回所有以'val_开头的元素'并隐藏它们。
I would like to return all the elements that begin with 'val_' and hide them.
我该怎么做?
推荐答案
使用属性选择器
$(document).ready(function(){
$("span[id^='val_']").hide();
});
这篇关于jQuery返回ID以某个字符串开头的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文