我有一个包含在表格中的表单,我已经负责使用表单构建器添加几个新的表单字段,因此我无法访问HTML代码来添加id或类。我添加了新字段,但为了完成显示/隐藏点击功能,目前适用于输入但不适用于与这些输入相关联的标签,这里是我拥有的JQuery(它只在没有冲突模式下运行) ):
jQuery(document).ready(function() {
jQuery('.bsd-dynamic-toggle-section-contributor tr input[name="company"]').hide();
jQuery('.bsd-dynamic-toggle-section-contributor tr td input[name="company"]').closest('label').hide();
jQuery('.bsd-dynamic-toggle-section-contributor tr input[name="title"]').hide();
jQuery('.bsd-dynamic-toggle-section-contributor tr td input[name="title"]').closest('label').hide();
//show it when the checkbox is clicked
jQuery('input[name="organization"]').on('click', function () {
if (jQuery(this).prop('checked')) {
jQuery('.bsd-dynamic-toggle-section-contributor tr input[name="company"]').show();
jQuery('.bsd-dynamic-toggle-section-contributor tr td input[name="company"]').closest('label').show();
jQuery('.bsd-dynamic-toggle-section-contributor tr input[name="title"]').show();
jQuery('.bsd-dynamic-toggle-section-contributor tr td input[name="title"]').closest('label').show();
} else {
jQuery('.bsd-dynamic-toggle-section-contributor tr input[name="company"]').hide();
jQuery('.bsd-dynamic-toggle-section-contributor tr td input[name="company"]').closest('label').hide();
jQuery('.bsd-dynamic-toggle-section-contributor tr input[name="title"]').hide();
jQuery('.bsd-dynamic-toggle-section-contributor tr td input[name="title"]').closest('label').hide();
}
});
});
相关的html是:
<td><table><tbody><tr><td>
<label class="fieldlabel"></label><input id="organization" name="organization" type="checkbox" value="1" class="checkbox"><label for="organization"> <label class="fieldlabel" for="custom1">My donation is on behalf of an organization</label></label>
</td></tr><tr><td>
<label class="fieldlabel">Organization Name<br></label><input id="company" size="30" name="company" type="text" class="text" style="display: inline-block;"></td></tr><tr><td>
<label class="fieldlabel">Title/Position<br></label><input id="title" size="30" name="title" type="text" class="text" style="display: inline-block;"></td></tr></tbody></table></td>
我需要定位组织名称和标题/位置的标签。我怎么能得到那些?
答案 0 :(得分:1)