简体   繁体   中英

Input / Change / Keyup / focus event not fired

I have this function:

showReview: function(){
            var main = document.getElementById("main");
            var ins =  main.getElementsByTagName("INPUT");
            var rev = $("reviewcontent").is(":hidden");
            for (var i = 0; i<ins.length; i++){
                $(ins[i]).on('show input keyup focus change', this.getInVals());
                console.log("Invals update from input");
            }
            if(!rev){
                this.addReview();
            }
        }

The events are fired when first loading the page but not when changing the input or focus on another input again. I have no clue why. I thought about that it only listens to the last input of the main but that is not the case.

$(ins[i]).on('show input keyup focus change', this.getInVals());

remove getInVals call. try change getInVals() to getInVals

$(ins[i]).on('show input keyup focus change', this.getInVals);

I don't get what you're trying to do or to say, but I was doing something similar, you can have it as an example if it helps.

$('.look').on('keyup change', function () {
    var value = $(this).val().toLowerCase();
    var what_place = $(this).parents('.collapse').find('.col-sm-0');
    $(what_place).each(function(){
        $(this).css({"display": "block"});
        if(value == ''){
            $(this).css({"display": "block"});
        }
        else if($(this).find('h5').text().toLowerCase().indexOf(value) < 0){
            $(this).css({"display": "none"});
        }
    });
});

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