JQuery trigger does not work in IE. What for?

$('#XynBp0').find('input').each(function(){
    if ($(this).attr('value') == 'Cancel'){
        $(this).trigger('click');
    }
});

not working in IE7

+3
source share
4 answers

Strange, but try creating a custom event

$('#XynBp0 input').bind('custom',function(){
 //code
})


$('#XynBp0').find('input').each(function(){
    if ($(this).attr('value') == 'Cancel'){
        $(this).trigger('custom');
    }
});

It works?

+2
source

$.click()(or $.trigger('click')) does not simulate a mouse click; it fires any onclick events associated with this element. If you have not scheduled an onclick event for this input you are looking for, nothing will happen.

, (, <input type="submit" value="Cancel">). $(yourform).submit() , , "".

+2

, dom? , .

$(function () {

    $('#XynBp0').find('input').each(function () {
        if ($(this).attr('value') == 'Cancel') {
            $(this).trigger('click');
        }
    });

});
0

snippit , , ?

$('input','#XynBp0').each(function () {
  var $this = $(this);
  if ( this.value === 'Cancel' ) { //Don't need jQuery here
    $this.trigger('click');  //Probably don't need it here either
  }
});

? , form.submit();

0

Source: https://habr.com/ru/post/1769648/


All Articles