有些物件透過 append 建立後,其 click 事件無效
$('.item').click(function(){ do_something(); });
改以透過 onclick 的方式即可
$(document).on('click', '.item', function(){ do_something(); });
有些物件透過 append 建立後,其 click 事件無效
$('.item').click(function(){ do_something(); });
改以透過 onclick 的方式即可
$(document).on('click', '.item', function(){ do_something(); });
# Array push for (var i = 0, a = []; i < 100; i++) a.push(0); # Array assign for (var i = 0, a = new Array(100); i < 100;) a[i++] = 0; # Typed array conversion (最慢) [].slice.call(new Uint8Array(100)); # Binary concatenation for (var i = 100, a = [], add = [0]; i; i >>=1) { if (i & 1) a.push.apply(a, add); add.push.apply(add, add); } # Array Apply Array.apply(null, new Array(100)).map(Number.prototype.valueOf,0); # Array.fill() (最快) new Array(100).fill(0);
Most efficient way to create a zero filled JavaScript array? – Stack
Overflow Zero filled array creation
CSS
iframe { max-width: 100%; }
Javascript
function adjustIframes() { $('iframe').each(function() { var $this = $(this); var proportion = $this.data('proportion'); var width = $this.attr('width'); var actual_w = $this.width(); if (! proportion) { proportion = $this.attr('height') / width; $this.data('proportion', proportion); } if (actual_w != width) { $this.css('height', Math.round(actual_w * proportion) + 'px'); } }); } $(window).on('resize load', adjustIframes);
formnovalidate="formnovalidate"
<button type="submit" formnovalidate="formnovalidate">提交表單不驗證</button>
使用 puttygen 產生 4096 bits 的 public/private key
mkdir ~/.ssh chmod 0700 ~/.ssh touch ~/.ssh/authorized_keys chmod 0644 ~/.ssh/authorized_keys sudo vi ~/.ssh/authorized_keys sudo vi /etc/ssh/sshd_config [...] PasswordAuthentication no [...] UsePAM no [...] systemctl restart sshd