我遇到此错误
“未捕获的TypeError:jQuery(...)。modal不是函数 HTMLButtonElement.onclick“
在此行
<button class="btn btn-default form-control" onclick="jQuery('#colorModal').modal('show'); return false;">Quantity and Color</button>
尝试打开此模式行:
<div class="modal fade modal-bg" id="colorModal" tabindex="-1" role="dialog" aria-labelledby="colorModalLabel" aria-hidden="true">
答案 0 :(得分:1)
Modal不是jQuery函数。 您的代码基于Bootstrap的Modal,因此您需要在jQuery之后立即嵌入引导程序:
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
这是一个生动的例子:https://jsfiddle.net/95mqj46d/4/