Jquery uncaught type error on html button element



我收到此错误

"Uncatch TypeError: jQuery(...(.模态不是函数 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">

Modal 不是 jQuery 函数。 你的代码是基于Bootstrap的Modal,因此你需要在jQuery之后嵌入bootstrap:

<!-- 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/

最新更新