How to trigger in input button?
i have a input button in a form:
<input type="submit" value="" class="hidde" name="free" id="helpdiv" onmouseover="this.style.background='url('../images/thank_you/thank.png');'" onmouseout="this.style.background='url('../images/thank_you/thank_you.png');'" style="width: 236px; height: 127px;">
and a jQuery script that has an event:
onlike:function(response){
$('.uncontent').hide('fade');
$('input#helpdiv').trigger('click');
}
when that function triggers i would like the input button to be triggered as well.
the function is working because $('.uncontent').h开发者_如何学Cide('fade');
gets triggered
any ideas?
Edit:
$('input#helpdiv').trigger('click')
or
$('input#helpdiv').click()
won't work for some reason
Try...
$('#helpdiv').click();
If you're trying to submit a form via this button select the <form>
element and call submit() on it like so....
$('#helpdiv').parents('form').eq(0).submit();
Your trigger is fine. You have some funky quotes going on in your mouseover events. This is why we should avoid doing that.
id="helpdiv" onmouseover="this.style.background='url('../images/thank_you/thank.png');'"
See the background='url('..
?
Try this:
HTML:
<input type="submit" value="" class="hidde" name="free" id="helpdiv" style="width: 236px; height: 127px;" />
JQuery:
$('#helpdiv').hover(function(){
$(this).css('background-image','url("../images/thank_you/thank.png")');
},function(){
$(this).css('background-image','url("../images/thank_you/thank_you.png")');
});
// Test it
$('#helpdiv').click(function(){
alert('helpdiv clicked');
});
Next step would be to abstract your CSS as well ;)
精彩评论