javascript - Input is not being focused -


i have table in inputs of last column user able type quantity of money. quantity evaluated , if not ok alert() message appears, input val() set $0,00 , same input should focused, seems focus() function not work.

the code seems me correct , when debug firebug works others don't. when type on firebug console $("id").focus() works fine. wondering if there's such person in world me problem!

$('#table [type=text]').val('$ 0,00').keyup(function () {     amf2005_becamecurrency(this, 20); }).blur(function () {     if (!validate($(this).val())) {         $(this).val('0,00');         $(this).focus();     }     amf2005_becamecurrency(this, 20);     $(this).val("$ " + this.value); }); 

this educated guess!

in code provided, calling "focus" event inside handler "blur" event. i'm not sure allowed, there simple way see.

try replacing $(this).focus() settimeout(function() { $(this).focus(); }, 0)

using settimeout function delay of 0 should make browser move focus right away, code no longer executed in context of blur handler.

also, mentioned alert function. fyi, there libraries jquery ui provide functions draw stylized dialogs part of page. these considered superior using alert function.


Comments

Popular posts from this blog

php - Magento - Deleted Base url key -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

javascript - Tooltipster plugin not firing jquery function when button or any click even occur -