我需要在相同的功能和控制台中获取父元素的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”变量,请帮助!
预先感谢
答案 0 :(得分:0)
从参考文献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);
}
});