开发者

How can I force in Jquery so that the focus event of a background changed textbox has the correct value?

I'm changing a textbox (child) based on a value entered by the user into an other textbox (parent).

This is done using following Jquery:

$(this).val(newData).trigger('change');

When changing directly the focus from the parent to the child textbox using the mouse or tabbing, the child textbox still has the old value in the focus event of the child textbox. On the blur event, the child textbox has the correct new value.

When I set the focus first to an totally different control, and then go to the child textbox, the value in the focus event of the child textbox is correct.

what is going on, and how can I force an update of the child textbox value, so that it is always registered in the focus开发者_JAVA技巧 event ?


perhaps you mean this? I prefer to use the

master -slave 

terminology in this case ;)

child = slave

like:

/** 
  just add/change events like change blur keyup keydown you can play with 
**/

$("input[name='master']").bind("blur", function() {
   $("input[name='slave']").val($(this).val());
});

test here:

http://jsfiddle.net/8SYKZ/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜