how to get YouTube video id from image thumbnail source, and set as an iframe?

前端 未结 3 431
情歌与酒
情歌与酒 2020-12-22 08:58

So if the image tag is


I don\'t know how to e

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-22 09:17

    Make the URL as an array and than take the second to last part. For example this also works with CSS background-image.

    id = $('div').attr('style').split('/');
    id = id[id.length-2];
    alert("YouTube ID: " + id);
    
    

    https://jsfiddle.net/Wobbo/wfyL1hem/7/

提交回复
热议问题