且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery-如何获取视频src值?

更新时间:2023-02-20 08:28:07

尝试一下,

实时演示

Live Demo

$('video source').each(function(num,val){
    console.log($(this).attr('src'));        // i am not getting this..
    $(this).attr('src', 'newSourceValue')
});

根据OP的评论,更改src文件名

Based on the comments by OP, changing the src filename

实时演示

Live Demo

$('video source').each(function(num,val){
    console.log($(this).attr('src'));        // i am not getting this..
    strSrc = $(this).attr('src'); 
    strPath = strSrc.substring(0, strSrc.lastIndexOf('/'));
    strExtenion = strSrc.substring(strSrc.lastIndexOf('.'));
    $(this).attr('src', strPath + "/" + "newFileName" + strExtenion );    
})​;