因此,我目前正在从事该项目,并且遇到了这个问题。我尝试查看控制台,但单击该按钮时未显示任何内容。我想做的是单击按钮时,它将触发文件输入,但是到目前为止,当我单击按钮时,什么也没有发生,甚至没有显示错误。(代码基于此处的回答问题:Bootstrap表单上传文件布局)你们可以帮我找出我做错了什么吗
这些是代码
TabUploadDokumen.html
<script>
$(document).ready(function () {
/* Some code here */
});
$('#btn_IdentitasKTP/Paspor').on('click', function () {
$('#file_IdentitasKTP/Paspor').trigger('click')
});
$('#file_IdentitasKTP/Paspor').change(function () {
var file_name = this.value.replace(/\\/g, '/').replace(/.*\//, '');
$('#text_IdentitasKTP/Paspor').val(file_name);
});
</script>
<!--Some other code -->
<div class='form-group'>
<label class='control-label'>Nama Dokumen<br /><span style='font-weight:normal;'>Silahkan scan/foto dokumen Anda disini</span></label>
<div class='form-group'>
<label for="text_IdentitasKTP/Paspor" id="lbl_IdentitasKTP/Paspor" class="control-label">Identitas(KTP/Paspor)</label>
</div>
<div class="input-group">
<input type="file" id="file_IdentitasKTP/Paspor" name="name_file_IdentitasKTP/Paspor" accept="image/jpg,image/jpeg,application/pdf,image/png" style="display: none" />
<input type="text" class="form-control" id="text_IdentitasKTP/Paspor" readonly />
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="btn_IdentitasKTP/Paspor">Upload KTP/Paspor</button>
</span>
</div>`
</div>
<!-- Some other code -->
我正在使用ASP.NET MVC 5和Bootstrap版本3.00,Jquery版本jquery版本1.11.1,如果有帮助的话。
提前致谢
您的选择器包含正斜杠,需要像这样进行转义:
$("#btn_IdentitasKTP\\/Paspor'")
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句