html 中有個ID [php] <span class="total">1</span> <span class="total">2</span> <span class="total">3</span> <span class="total">4</span> [/php] 利用jquery遍歷id 獲取累加和: [php] $a=0; $(".total").each(function(){ $a += Number($(this).text()); }); alert($a); [/php]
發(fā)表評論