简体   繁体   中英

Javascript and Jquery fire function when textbox changes

How can I fire those functions when I click buttons? I need to run it when some text has change. but I have a button on my page.. when I type it changes but when I use buttons to change the value it doesnt fire the functions(codes)

$(document).ready(function(){
var text1 = $(':text'),
    text2 = $(':text'),
    text3 = $(':text'),
    text4 = $(':text'),
    activeInput = text1;

activeInput.focus(); 

$(':text').on('focus', function(){

    activeInput = $(this);    
});

$(':button').on('click', function(){

    activeInput.val(activeInput.val()+ $(this).val());


 $('#dec').change(function(){
    fromdecimal();
 })

 $('#bin').bind('change click ', function(){
    frombinary();
 })

 $('#hex').bind('change click',function(){
    fromhexadecimal();
 })

 $('#oct').bind('change click',function(){
    fromoctal();
 })

  });  

});

are you using :(colon) to select class?? if yes then you are doing wrong.

use . (dot) to select class like

var text = $('.text');

for any other issue , show your html code.

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