简体   繁体   中英

an event that fire's when the textbox is changing from another element

i have 4 textbox's on my form 3 of them change the last textbox value every time they

assign new values.

iam trying to create an event that will trigger every time the last textbox value as changed

not only when the textbox leave focus or key up an down.

i tried this code but it doesn't work

 <input  class='textbox'  type='text'/>
 <input  class='textbox'  type='text'/>
 <input  class='textbox'  type='text'/>
 <input id='hex_color_textbox' class='textbox'  type='text'/> 

$("#hex_color_textbox").on('change keyup paste', function() 
{

});

any ideas?

thank you

you should put the change event on the other input's if you want the last input to be changed to the value of one of the three textboxes

$("input:not('#hex_color_textbox')").on("change", function() {
   var val = $(this).val()
   $("#hex_color_textbox").val(val);
});

If you want your code to react when the user is typing/pasting something, you can just say:

$("#hex_color_textbox").on('input', function() 
{
    //do your stuff
});

Here is the example: http://jsfiddle.net/dwYeC/

I have tried your code on jsbin.com and it works as you described with no problem. I used jquery 1.8

see code

what kind of browser are you using and what version of jQuery?

try below:-

$('#hex_color_textbox').change(function(){
    // do operation according to Your requirement
    alert("the value has changed");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM