我可以在javascript中使用元素名称吗?
问题描述:
我可以在javascript中使用元素名称吗?我可以在javascript中使用元素名称吗?
使用,我们使用
$('#xxx').prop('readonly', true);
而对于class="xxx"
,我们使用
$('.xxx').prop('readonly', true);
我想知道我们能在JavaScript中使用name="xxx"
什?
答
当然可以。
使用类似:
$('[name="xxx"]').prop('readonly', true);
在未来,提出新问题之前检查http://api.jquery.com/category/selectors/ – meagar 2014-10-05 15:59:38