想要隨機選擇每個tr內最後一個的td,
例如price2,price3,price1,price1這樣,
我是加上id再用隨機數去選,
有沒有更好的寫法,
功能
代碼
成交價
名稱
FITX
9238
臺指1610
FIMTX
9237
小臺1610
FIT5
9236
臺50指1610
var n = $("#price" + Math.floor(Math.random() * 3 + 1));
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
$("td:eq(0)")//第一个td
$("td:eq(1)")//第二个td
var a=""+Math.floor(Math.random() * 3 + 1);
var n = $("td:eq("+a+")");
var nTd = document.getElementsByTagName('td').length;
var nowTd = $("td:eq("+Math.floor(Math.random()*nTd)+")");