我想传递一个动态变化的字符串值。我可以将它分配给选项value = ...标签 likehere第一个选项vaue工作正常,但我想每次传递diff名称,所以我怎么能传递该字符串变量。
<script type="text/javascript">
var test="117960298357503_22120.mp4";
</script>
<OPTION value="J:\Users\ADITYARAJ SINGH\Downloads\Video\117960298357503_22120.mp4">My Video File </OPTION>
<OPTION value="J:\Users\ADITYARAJ SINGH\Downloads\Video\('+ test +')">My Video1 File </OPTION>
答案 0 :(得分:0)
给你的选项一个id,然后用jquery获取它并设置它的值:
HTML标记:
<OPTION value="J:\Users\ADITYARAJ SINGH\Downloads\Video\117960298357503_22120.mp4">My Video File </OPTION>
<OPTION value="" id="myoption">My Video1 File </OPTION>
和脚本:
$(function () {
var test = "117960298357503_22120.mp4";
$('#myoption').attr('value', 'J:\Users\ADITYARAJ SINGH\Downloads\Video\' + test);
});