English 中文(简体)
The charCode property of a keyup event should not be used. The value is meaningless
原标题:

HTML code:

<input type="text" id="secrecy" name="secrecy" size="3" maxlengh="3" />Days

Jquery code:

$( #secrecy ).keyup(function(){
alert("ok");    
});

Error message:

The charCode property of a keyup event should not be used. The value is meaningless.

The Jquery code doesn t work.When I input something into "secrecy", an alert doesn t come out.What s wrong?

最佳回答

Are you waiting to bind the event until the Dom is ready?

Something like this might help:

$(document).ready(function(){
  $( #secrecy ).keyup(function(){
    alert("ok");    
  });
});
问题回答

I tested your code and didn t see the error you mentioned, could you provide code that reproduces this error?

I was thinking that it could just be the browser you are using...

keyCode and charCode

The two properties are keyCode and charCode. Put (too) simply, keyCode says something about the actual keyboard key the user pressed, while charCode gives the ASCII value of the resulting character. These bits of information need not be the same; for instance, a lower case a and an upper case A have the same keyCode, because the user presses the same key, but a different charCode because the resulting character is different.

Explorer and Opera do not support charCode. However, they give the character information in keyCode, but only onkeypress. Onkeydown and -up keyCode contains key information.

From quirksmode site, but I don t see you using either in your example code. Are you using them?

That s not an error; it s a warning.

It s probably generated by code within jQuery that copies the properties of the event object to a wrapper that gets passed to your handler.

You should ignore it.

change charCode -> XcharCode in source jquery-1.X.X.js and everything works OK

in the lastest version 1.4.4 there are "4" ocurrences...

i ve a trouble too. I assign event to but there not work!

$(document).ready(function(){ $("#test ul").bind("keyup",function(){ alert( Handler for .keyup() called. ); });

})

I followed Diego s advice and the warnings went away in Firebug. Also saw the same advice here. http://api.jquery.com/keyup/#comment-108497941





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签