我正在尝试在我的网页中实现此搜索栏:https://github.com/jeffersonRibeiro/jquery-simpleSelect 但是当我导入引导程序时它似乎不起作用。
我试图查看我是否错误地导入了东西,但是似乎没有任何作用。搜索栏唯一实际可行的方法是,如果我注释掉了bootstrap import
我正在使用的导入仅来自:https://getbootstrap.com/docs/4.0/getting-started/introduction/。仅链接Bootstrap样式表似乎无法使其正常工作,我不确定为什么。有什么想法吗?
这是html文件:
$(document).ready(function(){
$('#segment').simpleSelect();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<meta charset="UTF-8">
<title>Simple select with search</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> -->
<link rel="stylesheet" href="simpleSelect.css">
</head>
<body>
<form>
<select id="segment" name="segmentation">
<option data-defaultSelected>Select</option>
<option>JAVASCRIPT</option>
<option>PHP</option>
<option>BRAZIL</option>
<option>CANADA</option>
<option>MEAN</option>
</select>
<!-- <input type="submit"/> -->
</form>
JavaScript:https://github.com/jeffersonRibeiro/jquery-simpleSelect/blob/master/src/js/simpleSelect.js
CSS:https://github.com/jeffersonRibeiro/jquery-simpleSelect/blob/master/src/css/simpleSelect.css
当我取消注释引导样式表的链接时,会发生问题
答案 0 :(得分:1)
./
表示当前目录。
因此,更改<script src="./src/js/simpleSelect.js"></script>
以访问正确的目录。
要运行jQuery函数,需要将它们包装在函数或文档中。就绪
<script>
$(document).ready(function(){
$('#segment').simpleSelect();
});
</script>