jQuery div or using input field name

Wednesday, November 4, 2015

I have a question regarding the input box below. I'm using jQuery to capture
the input field. Do you need do have a surrounded div or can you use the name attribute from the html form tag?



<input type="text" name="name" size="30">


and



var MIN_LENGTH = 3;
$(document).ready(function() {
$("#keyword").keyup(function() {
var keyword = $("#keyword").val();
if (keyword.length >= MIN_LENGTH) {
$.get( "auto-complete.php", { keyword: keyword } )
.done(function( data ) {
console.log(data);
});
}
});

});


what's the right way of doing it?

0 comments:

Post a Comment