I have tried everything to get this to work on ALL platforms. What am I doing wrong?
JS–
$(document).ready(function(){
$('#gname').keypress(function() {
if ($(this).val() == "Toys")
$('#number').slideDown('fast')
else
$('#number').hide();
});
});
CSS–
#number { display: none; height: 100px; border: solid 1px #ddd; }
HTML–
Type here:<input type="text" id="gname">
<div id="number">
Test
</div>
If you bind to the
keyupevent rather thankeypressthe value will have been changed by the time the event handler runs: http://jsfiddle.net/azHQz/A demo for only checking the value when the enter key is pressed: http://jsfiddle.net/azHQz/1/