我需要在同一个函数和控制台中获取父元素的 id
我试图获取绑定函数的父元素的 id
$('#customized-player').mediaelementplayer({
alwaysShowControls: true,
features: ['progress', 'duration', 'tracks' ],
audioVolume: 'horizontal',
audioWidth: 450,
timeFormat: 'mm:ss',
startVolume: .6,
success: function (instance) {
var thisID = $(this).parents(".audio-player").attr('id');
console.log("Parent ID is:" + thisID);
}
});
我想获得这个“#customized-player”的父元素的id,正如你在上面的代码中看到的那样。我已经初始化了一个名为“thisID”的变量,请帮忙!
提前致谢
从参考https://github.com/mediaelement/mediaelement/blob/master/docs/usage.md#jquery更新您的success
函数如下。
$('#customized-player').mediaelementplayer({
alwaysShowControls: true,
features: ['progress', 'duration', 'tracks' ],
audioVolume: 'horizontal',
audioWidth: 450,
timeFormat: 'mm:ss',
startVolume: .6,
success: function (mediaElement, originalNode, instance) {
var thisID = $(originalNode).parents(".audio-player").attr('id');
console.log("Parent ID is:" + thisID);
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句