I have a onkey on a input but it won't find the function I have in my js file. I searched through some questions on here but can't find the solution for it.
My input code:
<input id="Name" type="text" name="name" class="form-control" onkeyup="autocomplet()">
<ul id="Name_list_id"></ul>
jQuery:
function autocomplet() {
var min_length = 0;
var keyword = $('#Name').val();
if (keyword.length >= min_length) {
$.ajax({
url: "search.php",
type: "POST",
data: {keyword:keyword},
success:function(data){
$('#Name_list_id').show();
$('#Name_list_id').html(data);
}
});
} else {
$('#Name_list_id').hide();
}
}
function set_item(item) {
$('#Name').val(item);
$('#Name_list_id').hide();
}
JS files of tutorial:
<script type="text/javascript" src="js/jquery.min.js">
</script> <script type="text/javascript" src="js/script.js"></script>
and on my website:
<script src="s/jquery-2.1.3.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/events.js"></script>
<script src="js/jquery-ui.js"></script>
<script src="js/jquery-ui.min.js"></script>
Thanks!
<!DOCTYPE html>
<html>
<head>
<title>- jsFiddle demo by vilaskumkar</title>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<script src="http://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js" type="text/javascript"></script>
<script src="js/events.js" type="text/javascript"></script>
<!-- Add all you JS File in head -->
<!-- <link href="/css/result-light.css" rel="stylesheet" type="text/css"> -->
</head>
<body>
<form>
<input class="form-control" id="Name" name="name" onkeyup=
"autocomplet()" type="text">
</form>
<ul id="Name_list_id"></ul>
</body>
</html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.