如果我的页面上有一些不必要的元素
id
,就像ASP.Net-MVC
中的HTML Helper
一样。那么这会减慢我的id
选择器的性能吗?(我有一个包含大量元素的页面)// First DOM
<HTML>
...
<input type="text" value="first" id="useless" />
<input type="text" value="second" id="useful" />
</HTML>
// Second DOM
<HTML>
...
<input type="text" value="first"/>
<input type="text" value="second" id="useful" />
</HTML>
脚本:
<script>
alert($('#useful').val());
// never select the first element (with the useless id)
</script>