【发布时间】:2017-07-12 10:59:06
【问题描述】:
我怎样才能做到这一点?变量范围包含菜单或内容。所以我需要它来查找 ID 为 Scope_Menu 或 Scope_Content 的输入,具体取决于变量范围。
var scope = $(this).data('scope');
$('#frmEditPagevar').find('input[id="Scope_ + scope"]').prop("checked", true);
【问题讨论】:
-
使用
$('#Scope_' + scope).prop("checked", true) -
.find('input[id="Scope_" + scope + "]') -
模板文字 -
.find(`input[id="Scope_${scope}"]`)- 对我来说更具可读性 developer.mozilla.org/en/docs/Web/JavaScript/Reference/…
标签: javascript jquery variables jquery-selectors