use*_*937 0 html javascript jquery
我有一个简单的html选择如下:
<select id="eventid">
<option value="a">a</option>
<option value="b">b</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我使用的脚本使用此代码,我必须获取选择值.
<script id="template-upload" type="text/x-tmpl">
<tr class="template-upload fade">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<td class="post"><label><input type="hidden" name="userid[]" value="$( "#eventid" ).val()" required></label></td>
Run Code Online (Sandbox Code Playgroud)
我认为它不起作用因为x-tmpl脚本标题但我必须使用它.如何获取此tmpl脚本中的选择值?
谢谢
这是一个引用不匹配,改变:
value="$( "#eventid" ).val()"
Run Code Online (Sandbox Code Playgroud)
至
value="$('#eventid').val()"
Run Code Online (Sandbox Code Playgroud)
并且希望你使用的任何奇怪的模板系统都允许你直接在值属性中使用jQuery?