I have the following function:
$(document).ready(function() {
$(\"#dSuggest\").keypress(function() {
var dInput = $(\'input:text[name=dSuggest]\'
This is because Keypress event is fired before the new character is added. Use 'keyup' event instead,which will work perfectly in your situation.
$(document).ready(function() {
$("#dSuggest").keyup(function() {
var dInput = $('input:text[name=dSuggest]').val();
console.log(dInput);
$(".dDimension:contains('" + dInput + "')").css("display","block");
});
});
I want to add to this, if you have many textboxes and you have to do the same thing on their keyup event you can simply give them a common css class(eg commoncss) and apply keyup event like this.
$(document).ready(function() {
$(".commoncss").keyup(function() {
//your code
});
});
this will greatly reduce you code as you don't have to apply keyup event by id for each textboxes.