Convert jquery to javascripts

Hello All.
Can you help me convert this file jquery to file javascripts. Thank you verry much.
$( document ).ready(function() {
$(‘div[data-type=“videoplayer”]’).each(function (index) {
var videoId = $(this).attr(‘data-vid’);
var targetId = $(this).attr(‘id’);
var embedUrl = ‘http://embed.mecloud.vn/play/’; // Server production
//var embedUrl = ‘http://embed.cloud.meme.vn/play/’; // Server dev
var embedJs = ‘//</script>’;
$(‘body’).append(embedJs);}); });

Something like the following is what I’d do.

function initPlayer(player) {
    var videoId = player.getAttribute('data-vid'),
        targetId = player.id,
        embedUrl = 'http://embed.mecloud.vn/play/', // Server production
        // embedUrl = 'http://embed.cloud.meme.vn/play/', // Server dev
        embedJs = '...';
    // other code here
}

var videoPlayers = document.querySelectorAll('div[data-type="videoplayer"]'),
    i;
for (var i = 0; i < videoPlayers.length; i += 1) {
    initPlayer(videoPlayers[i]);
}

the good news is that this is already JavaScript …

1 Like

Hi Paul_Wilkins,
Thank you verry much !

Hi Dormilich,
Thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.