admin管理员组文章数量:1429950
I have a standard input type text field that is supposed to trigger a Javascript whenever it is changed. First I tried onChange, however it just did nothing. Then I tried onBlur, but also here it did not do anything.
HTML Code:
<input type="text" size="1" class="inputbox" onblur="c();" name="qty" value="1" />
The Javascript should not be the problem, because I am triggering this with another select dropdown menu as well and there it works fine! Just on this text field it seems not to work. Anyways, here's the Javascript code:
function c() {
$('#add4').fadeOut(function(){
$('#add5').css('visibility', 'visible');
document.u.submit();
});
}
I checked online, but could not find any relevant posts or hints in this regard whatsoever. Any ideas what's wrong?
I have a standard input type text field that is supposed to trigger a Javascript whenever it is changed. First I tried onChange, however it just did nothing. Then I tried onBlur, but also here it did not do anything.
HTML Code:
<input type="text" size="1" class="inputbox" onblur="c();" name="qty" value="1" />
The Javascript should not be the problem, because I am triggering this with another select dropdown menu as well and there it works fine! Just on this text field it seems not to work. Anyways, here's the Javascript code:
function c() {
$('#add4').fadeOut(function(){
$('#add5').css('visibility', 'visible');
document.u.submit();
});
}
I checked online, but could not find any relevant posts or hints in this regard whatsoever. Any ideas what's wrong?
Share Improve this question asked Oct 29, 2013 at 17:09 KoljaKolja 8684 gold badges11 silver badges32 bronze badges 3- 2 Remove the inline event handler and use proper event handlers, and it will probably work, as I'm guessing wildly you put the c() function inside document ready or something else strange. – adeneo Commented Oct 29, 2013 at 17:12
- @adeneo, you should make your ment an answer. – Ishmael Commented Oct 29, 2013 at 17:16
- Is there an error in the console? – epascarello Commented Oct 29, 2013 at 17:18
2 Answers
Reset to default 3try this
<form>
<input id="target" type="text" value="Field 1">
<input type="text" value="Field 2">
</form>
<div id="other">
Trigger the handler
</div>
The event handler can be bound to the first input field:
$( "#target" ).blur(function() {
alert( "Handler for .blur() called." );
});
check this links for your reference http://api.jquery./blur/
http://www.w3schools./jquery/tryit.asp?filename=tryjquery_event_blur_alert
Hope this help
This may solve your problem:
<input type="text" size="1" class="inputbox" onblur=" javascript:c(); " name="qty" value="1" />
本文标签: javascriptBoth onBlur and onChange not working with ltinput typequottextquotStack Overflow
版权声明:本文标题:javascript - Both onBlur and onChange not working with <input type="text" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745498128a2660902.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论