我需要在某些選擇器上設置tap
觸發器。我正在使用jQuery Mobile和這個功能,所以什麼是不對的?如何用jQuery觸發點擊事件
window.onload = load;
function load() {
$('.togglePlay').trigger('tap');
}
我需要在某些選擇器上設置tap
觸發器。我正在使用jQuery Mobile和這個功能,所以什麼是不對的?如何用jQuery觸發點擊事件
window.onload = load;
function load() {
$('.togglePlay').trigger('tap');
}
假設加載頁面具有包含data-role=page
及其id
一個div被mypage
,你可以在'.togglePlay'
這樣使用pageinit
事件火了click
:
$(document).on("pageinit", "#mypage", function() {
$('.togglePlay').trigger('click');
});
參考文獻
ready
事件,看到從JQM API頁面事件jQuery Mobile: document ready vs page events你應該能夠設定自動播放= true或一些其他設置與...
<video controls autoplay>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
例如來自:
不使用js
這與問的問題無關 – Belfordz
也許你應該使用$ .ready函數,而不是窗口的onload事件 –
$(文件)。就緒(函數(){ – suhailvs
這沒有幫助 – Lukas