twitter-bootstrap 未捕获的类型错误:$(...).modal 不是函数 jquery
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37464194/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught TypeError: $(...).modal is not a function jquery
提问by uche
I have a jquery script to show modal form
我有一个 jquery 脚本来显示模态表单
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
$(".manipulate").click(function(){
$('#id_description').val();
var item_keys = ['#id_counter', '#id_first_name','#id_middle_name', '#id_last_name', '#id_display_name', '#id_field', '#id_loa_price', '#id_basic_cert_price', '#id_written_appraisal_cost']
for(var i=1; i<12; i++){
var item_val = $(this).parent().parent().find('td:nth-child('+i+')')[0].innerText;
console.log("InnerText is :"+ item_val);
$(item_keys[i-1]).val(item_val);
}
$('#id_item').val($(this).attr('item_id'));
$('#edititemModal').modal("show");
});
});
</script>
If i click the edit button to show the modal form i get .modal not a function.
如果我单击编辑按钮以显示模态表单,我会得到 .modal 不是函数。
回答by Destrif
<script type="text/javascript">
not
不是
<script>
Also follow the right order: Bootstrap modal: is not a function
还要遵循正确的顺序: Bootstrap modal: is not a function
回答by Kuldeep Kumar
I resolved it after adding the library inside the index.js.We think you need this liabrary,bootstrap.js please add inside the index.js and i hope your code works will fine.
我在 index.js 中添加库后解决了它。我们认为您需要这个库,bootstrap.js 请添加到 index.js 中,我希望您的代码能够正常工作。

