在每个表上运行jQuery [英] Run jquery on each table
问题描述
下面,我有一些jQuery,它们通过类名= sizetable遍历每个表
Below I have some jQuery that runs through each table with the classname = sizetable
我要执行此操作:
$("#frontshade :radio").click(function() {});
但是我不确定如何用数组中的ID替换#frontshade
But I'm not sure how to replace the #frontshade
with the id from the array
var table_ids = new Array();
$('.sizetable')
.each(function(e){
table_ids[] = $(this).attr('id');
// JQUERY TO EXECUTE ON EACH TABLE
$("#frontshade :radio").click(function() {};
//
});
推荐答案
您可以编写$(this).find('input:radio')
.
.find()
方法查找与选择器匹配的所有后代.
You can write $(this).find('input:radio')
.
The .find()
method finds all descendants that match a selector.
请注意, input:radio
比:radio
快.
如文档所述,
Note that input:radio
is faster than :radio
.
As the documentation states,
$(':radio')
等效于$('[type=radio]')
.和其他一样 伪类选择器(那些 建议以:"开头 在其前面加上标签名称或一些 其他选择器否则, 暗含通用选择器("*"). 换句话说,裸$(':radio')
等价于$('*:radio')
,所以 应使用$('input:radio')
代替.
$(':radio')
is equivalent to$('[type=radio]')
. As with other pseudo-class selectors (those that begin with a ":") it is recommended to precede it with a tag name or some other selector; otherwise, the universal selector ("*") is implied. In other words, the bare$(':radio')
is equivalent to$('*:radio')
, so$('input:radio')
should be used instead.
这篇关于在每个表上运行jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!