Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以
$(".section").attr("name", function (arr) { return "section" + arr; })
显然给
<div class="section" name="section0"></div> <div class="section" name="section1"></div> <div class="section" name="section2"></div>
如何使部分从 1 开始?
干杯!
$(".section").attr("name", function (arr) { return "section" + (arr+1); })