我有来自videojs的视频:
<video id="movie" class="video-js vjs-default-skin" controls
preload="auto" width="638" height="480" poster="resources/movies/botschafter/1/test/skins/express_show_silver/video_titel.png"
data-setup="{}">
<source src="resources/botschafter/module1/1/test/botschafter_herkunft.flv" type='video/mp4' />
<source src="my_video.webm" type='video/webm' />
</video>
我想动态构建源代码。现在它是静态的:<source src="resources/botschafter/module1/1/test/botschafter_herkunft.flv" type='video/mp4' />
我喜欢这样:
var moduleName ; var stepNr ;
<source src="resources/botschafter/"+ moduleName +"/"+ stepNr +"/test/botschafter_herkunft.flv" type='video/mp4' />
只是因为src已经用“”包围,如何将新变量插入其中?
答案 0 :(得分:1)
这样做:
var code = '<source src="resources/botschafter/' + moduleName +'/'+ stepNr + '/test/botschafter_herkunft.flv" type="video/mp4" />'
您可以在单引号内使用双引号:'he said: "I love you!"'
和向后:"he said: 'I love you!'"
。此外,您可以在字符串中屏蔽符号:"Here's some \"quoted\" text"