admin管理员组文章数量:1333185
"currentSrc" is the only option I have to switch source src in html5 video in with multiple source (*.mp3, *.ogg etc.)
"currentSrc" throws "undefined" if I use inside Jquery. But it works fine, if I call this in the html page.
In detail: My Video Source:
<video width="630" height="354" id="video1" class="video1" poster="asserts/poster.png" controls="controls" data-name="demo video" data-uid="57fb2708">
<source src=".mp4" data-quality="sd" />
<source src="asserts/samllfile.mp4" data-quality="hd" />
<source src=".webm" data-quality="hd" />
<source src=".webm" data-quality="sd"/>
<source src=".webm" data-quality="hd" />
</video>
Get current video URL
Javascript in the html page (which works fine):
myVid=document.getElementById("video1");
function getVid(){
alert(myVid.currentSrc);
};
Line inside Jquery (throws "undefined"):
alert($hdVideo.currentSrc);
Please help me out...
"currentSrc" is the only option I have to switch source src in html5 video in with multiple source (*.mp3, *.ogg etc.)
"currentSrc" throws "undefined" if I use inside Jquery. But it works fine, if I call this in the html page.
In detail: My Video Source:
<video width="630" height="354" id="video1" class="video1" poster="asserts/poster.png" controls="controls" data-name="demo video" data-uid="57fb2708">
<source src="http://static.clipcanvas./sample/clipcanvas_14348_H264_320x180.mp4" data-quality="sd" />
<source src="asserts/samllfile.mp4" data-quality="hd" />
<source src="http://static.clipcanvas./elephants-dream.webm" data-quality="hd" />
<source src="http://video.webmfiles/big-buck-bunny_trailer.webm" data-quality="sd"/>
<source src="http://video.webmfiles/elephants-dream.webm" data-quality="hd" />
</video>
Get current video URL
Javascript in the html page (which works fine):
myVid=document.getElementById("video1");
function getVid(){
alert(myVid.currentSrc);
};
Line inside Jquery (throws "undefined"):
alert($hdVideo.currentSrc);
Please help me out...
Share Improve this question asked Oct 5, 2012 at 15:01 Vel Murugan SVel Murugan S 5803 gold badges12 silver badges31 bronze badges2 Answers
Reset to default 5Because a jQuery object does not have a property currentSrc so it returns undefined.
alert( $hdVideo.get(0).currentSrc );
alert( $hdVideo[0].currentSrc );
alert( $hdVideo.prop("currentSrc") ); //might be attr() instead of prop()
DOM elements and jQuery-wrapped DOM elements do not have the same properties or methods. If you want to access a property of the DOM element from a jQuery-wrapped DOM element, you need to use get()
or an indexor to access the underlying DOM element:
alert($hdVideo.get(0).currentSrc);
alert($hdVideo[0].currentSrc);
本文标签: javascriptcurrentSrc not working inside jquery pluginStack Overflow
版权声明:本文标题:javascript - currentSrc not working inside jquery plugin - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742275710a2445155.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论