<input type='number' id='panelClanMemberPerm_0' value='10' />
<input type='text' id='panelClanMemberRank_0' value='Owner' />
<div onclick='panelClanSaveMember(0);'> Update</div>
<div id='result1'></div>
<div id='result2'></div>
<script>
function panelClanSaveMember(id_member)
{
const _perm = `panelClanMemberPerm_${id_member}`;
const _rank = `panelClanMemberRank_${id_member}`;
const perm = $(_perm).val();
const rank = $(_rank).val();
$(result1).html(perm);
$(result2).html(rank);
}
</script>
如何通过这种方式从输入中获得价值? 我必须通过使用函数来获得这个值:)
答案 0 :(得分:0)
要在jQuery中通过ID选择元素,您需要使用#
符号。尝试将其更改为:
const _perm = `#panelClanMemberPerm_${id_member}`;
const _rank = `#panelClanMemberRank_${id_member}`;