Reputation: 101
I can't figure out what's wrong in my code.
I've checked stackoverflow for similar questions but nothing have helped me
I import my js files
<link type="text/css" href="Scripts/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript" src="Scripts/jquery-ui.js"></script>
Then I write the js for the autocomplete:
<script>
function log(msg) {
$("<div>", { text: msg }).prependTo("#log");
}
$("#elem").autocomplete({
source: ["Javascript", "Java", "Jino"],
minLength: 1,
fillin:true,
change: function (event, ui) {
console.log(ui.item);
}
});
$("#elem").autocomplete("widget").height(300);
</script>
then I write the html:
<input id="elem" />
<div id="log"></div>
It is supposed to work, I don't get any errors on IE. I browsed through tons of example, nothing works, I'm desperate <.<
jsfiddle: http://jsfiddle.net/2d6fLepa/
Upvotes: 0
Views: 338
Reputation: 101
It works now, Thanks to Robert
$(function(){
function log(msg) {
$("<div>", { text: msg }).prependTo("#log");
}
$("#elem").autocomplete({
source: ["Javascript", "Java", "Jino"],
minLength: 1,
fillin:true,
change: function (event, ui) {
console.log(ui.item);
}
});
$("#elem").autocomplete("widget").height(300);
});
Upvotes: 1