HTML:getContext模糊效果,找不到this.prev('canvas')?
<div class="span">
<canvas></canvas>
<video autoplay loop muted onloadeddata="loaded(this)">
<source src="xxx.mp4" type="video/mp4">
</video>
</div>
<div class="span">
<canvas></canvas>
<video autoplay loop muted onloadeddata="loaded(this)">
<source src="yyy.mp4" type="video/mp4">
</video>
</div>
JS:
function draw(v, c, w, h) {
if (v.paused || v.ended) return false;
c.drawImage(v, 0, 0, w, h);
setTimeout(draw, 1, v, c, w, h);
};
function loaded(vid) {
$(vid).on('play', function() {
var $this = $(vid).prev('canvas'),//this one dont work?
$this = $('canvas').get(0),//i dont want this get(x), i need "this"
cw = Math.floor($this.clientWidth/1),
ch = Math.floor($this.clientHeight/1);
$this.width = cw;
$this.height = ch;
draw(this, $this.getContext("2d"), cw, ch);
});
};
爲什麼我不能找到 「這個」 ???
$ this = $(vid).prev('canvas'),//這個不工作?
$此= $( '畫布')得到(0),//我不想這樣得到(X),我需要 「這個」
感謝的人,幫我解決這個問題。 https://codepen.io/anon/pen/YrJqwQ
好的工作的人,謝謝 – tester4