gpt4 book ai didi

jquery - jplayer和jquery,添加一个函数

转载 作者:行者123 更新时间:2023-11-30 09:04:15 25 4
gpt4 key购买 nike

jQuery("#jquery_jplayer_1").jPlayer({
ready: function () {
jQuery(this).jPlayer("setMedia", {
mp3: "/wp-content/themes/casaluna/music/01_Yari.mp3",
oga: "/wp-content/themes/casaluna/music/01_Yari.ogg"
}).jPlayer("play");
[...]

您好,在触发事件“播放”的地方,我想添加对函数的引用。(这将检查是否在主页上)

我在哪里以及如何将这个部分分开,以添加新功能?

最佳答案

根据documentation ,您可以像这样将处理程序附加到播放事件:

$("#jquery_jplayer_1").bind($.jPlayer.event.play, function(event) { // Add a listener to report the time play began
// Get the pathname and homepage values in a manner suitable to your
// application before the following check.
if ( pathname != homepage ) {
return false;
}
});

如果你需要解绑你的函数,你可以这样做:

$("#jquery_jplayer_1").unbind($.jPlayer.event.play); // Remove all play event listeners

您可以在 jQuery onload 函数 ($(function() {...});) 的任何位置插入此代码以附加处理程序。

关于jquery - jplayer和jquery,添加一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6455173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com