Skip to content Skip to sidebar Skip to footer

Jquery Trigger Not Working In Ie. Why?

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

Solution 1:

it's strange but try to create a custom event

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


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

Does this work?

Solution 2:

$.click() (or $.trigger('click')) doesn't simulate a mouse click; it fires off any onclick events bound to that element. If you haven't assigned an onclick event to that input you're searching for, nothing will happen.

It sounds like you're trying to submit the form with a traditional submit button (e.g. <input type="submit" value="Cancel">). If that's the case, you may have to use $(yourform).submit() to submit the form, in combination with some handling of the data sent to the server to simulate clicking the Cancel button.

Solution 3:

Is it wrapped in a dom ready event? Might help if you provide more code.

$(function () {

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

});

Solution 4:

Your code snippit doesn't make any sense, you are clicking inputs if they are canceled?

Here's some things to clean up in your code

$('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
  }
});

What does click even do? If you are trying to submit a form, use form.submit();

Post a Comment for "Jquery Trigger Not Working In Ie. Why?"