0

我有一个来自 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 stepNr ;

<source src="resources/botschafter/"+ moduleName +"/"+ stepNr +"/test/botschafter_herkunft.flv" type='video/mp4' />

只是因为src已经被“”包围了,如何插入新变量?

4

1 回答 1

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"

于 2013-09-30T13:01:43.510 回答