jQuery通配符 [英] Jquery wild card character

查看:109
本文介绍了jQuery通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个控件,其ID为control_1control_2control_3.

I have 3 controls with id control_1, control_2, control_3.

我想隐藏这些控件.

当前我正在使用此

$('#control_1').hide();
$('#control_2').hide();
$('#control_3').hide();

有更好的方法吗?

我可以做类似$('control_*').hide();的事情吗?

Can I do something like $('control_*').hide();?

是否可以找到以特定名称开头的控件?

Is there a way to find controls with start with a specific name?

推荐答案

为完整起见,您可以使用属性过滤器开始:

For completeness, you can use the starts with attribute filter:

$('[id^="control_"]').hide();

也就是说,在大多数情况下,最好采用其他建议之一.

That said, for most purposes it would be better to go with one of the other suggestions.

这篇关于jQuery通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆