我正在尝试使用滚动条创建一个大型HTML表(大约5000行),所以我考虑将该表插入一个<div>
我可以随后格式化的表格.
它在Firefox 47和IE 11中运行良好,但在Chrome 59中滚动时表现不佳.
<!DOCTYPE html>
<html>
<head>
<title>Test page</title>
</head>
<body>
<div style="width: 400px; height: 300px; overflow: scroll;" id="test"></div>
<script>
let table = '<table style="table-layout: fixed; width: 3000px">';
table += '<thead>';
table += '<tr>';
for(let i=0; i < 30; i++) {
table += '<th style="width: 100px">#' + i +'</th>';
}
table += '</tr>';
table += '</thead>';
table += '<tbody>';
for(let i=0; i < 5000; i++) {
table += '<tr>';
for(let j=0; j < 30; j++) …
Run Code Online (Sandbox Code Playgroud) 我是Git的新手,当我git init
在终端中运行时,没有创建.git目录,但是我得到了这个结果Reinitialized existing Git repository in /Users/Desktop/Javascript/sotrustme/.git/
请帮我
我正在为体育赛事做一个 php 应用程序,在某些情况下,得分的最小值是赢家。就像如果有 100 米赛跑比赛,那么获胜者就是跑得最快的。获胜者有最短的时间完成比赛。
但是我面临的是,当有人缺席或在完成之前退出时,我们提供的分数为零。在这种情况下,当我们要排序时,第一个位置将是零。但这应该是最后。
下面是我在 javascript 中的代码
var sorted = $(".result").sort(function (ib1, ib2) {
return parseFloat($(ib2).val()) - parseFloat($(ib1).val());
});
// Result Names
$('#result_first').val($("#participant"+$(sorted.get(9)).data("section")).val());
$('#result_second').val($("#participant"+$(sorted.get(8)).data("section")).val());
$('#result_third').val($("#participant"+$(sorted.get(7)).data("section")).val());
$('#result_fourth').val($("#participant"+$(sorted.get(6)).data("section")).val());
$('#result_fifth').val($("#participant"+$(sorted.get(5)).data("section")).val());
$('#result_sixth').val($("#participant"+$(sorted.get(4)).data("section")).val());
$('#result_seventh').val($("#participant"+$(sorted.get(3)).data("section")).val());
$('#result_eighth').val($("#participant"+$(sorted.get(2)).data("section")).val());
$('#result_ninth').val($("#participant"+$(sorted.get(1)).data("section")).val());
$('#result_tenth').val($("#participant"+$(sorted.get(0)).data("section")).val());
// Result Numbers
$('#result_first_no').val($(sorted.get(9)).val());
$('#result_second_no').val($(sorted.get(8)).val());
$('#result_third_no').val($(sorted.get(7)).val());
$('#result_fourth_no').val($(sorted.get(6)).val());
$('#result_fifth_no').val($(sorted.get(5)).val());
$('#result_sixth_no').val($(sorted.get(4)).val());
$('#result_seventh_no').val($(sorted.get(3)).val());
$('#result_eighth_no').val($(sorted.get(2)).val());
$('#result_ninth_no').val($(sorted.get(1)).val());
$('#result_tenth_no').val($(sorted.get(0)).val());
Run Code Online (Sandbox Code Playgroud)
请帮我对这些值进行排序,零值应该放在最后。
我指的是这个问题:Pick random property from a Javascript object
在标记的答案中,作者使用了以下代码:
if (Math.random() < 1/++count)
result = prop;
Run Code Online (Sandbox Code Playgroud)
我的问题:
谢谢!