I have an input that I need on enter keypress
to check if input = no, nope, none
(and so on, a number of words I select) the #preview container to have the value x, else, the preview container have the value y.
What I have so far doesn't work and I can't figure out why : jsFiddle
Script:
$('input').bind('keypress', function(e) {
if(e.keyCode==13){
if(('input').val() =='no'){
$('#preview').html('No email').fadeIn(800);
}, else {
$('#preview').html('Email: ' + '<strong style="color:#fd8a64;">' + $(this).val().toLowerCase() + '</strong>').fadeIn(800);
}
}
});
Try to use this code:
$('input').bind('keypress', function(e) {
if(e.keyCode==13){
if($(this).val() =='no'){
$('#preview').html('No email').fadeIn(800);
} else {
$('#preview').html('Email: ' + '<strong style="color:#fd8a64;">' + $(this).val().toLowerCase() + '</strong>').fadeIn(800);
}
}
});