Ok so I have this form. In the form is an input field, that when you type a ? somewhere in the input value, I have a section of code that runs an onkeyup that slides out an element (.searchEnter) as well as changing some css.
<script>
$(".askInput").keyup(function() {
if ($(this).val().indexOf("?") != -1) {
$('.searchEnter').animate({
marginLeft: "310px"
}, 200 );
$('.form1').get(0).setAttribute('action', 'post.php');
} else {
$('.searchEnter').animate({
marginLeft: "250px"
}, 200 );
$('.form1').get(0).setAttribute('action', 'search.php');
}
});
</script>
When I just type a question mark in the input, .searchEnter slides out right away. However, the more characters that are preceding the question mark, (i.e. What is your name? (17 characters before ?) ), the longer it takes for the .animate to kick in and slide .searchEnter out. Why is this occurring, and how can I fix it?
Try $(‘.searchEnter’).stop().animate …