JQuery failed to detect hidden domain hidden to trigger onchange event

< input type= "hidden" name= "blk" onchange= "test ();" value= "" / >
Why is the onchange event not triggered when the value in blk changes when using the js script, and how can the test () method be executed?

Apr.01,2021
The

onchange event can only be triggered when the content of the input box changes when the input box loses focus. I guess you want to listen for the input event, please use onkeyup, so that each input character will trigger the event.


input event ~ or trigger ('change')


onchange is triggered only after it gains focus and then loses focus. Direct dom manipulation assignment can extend jquery, to add a _ val method instead of jq's own val

        $.fn.extend({_val:function(newVal){
            var originalVal = $(this).val();
            if(newVal!==originalVal) {
                $(this).val(newVal);
                $(this).trigger("change");
            }
        }})

use $('input [name = blk]'). _ val (12345) when assigning a value to input.

if you look at your scene, you don't have to extend jQuery as above. If there are only one or two uses, you can also use val assignment and trigger the event directly by calling trigger ("change") . It's just a little ugly.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46ad1-44412.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46ad1-44412.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?