English 中文(简体)
我如何获得每个关键人物的价值,并在一个与 j合的变量中加以利用?
原标题:How do I get the value of each key pressed and use it in a variable with jQuery?

我如何获得每个关键人物的价值,并在一个与 j合的变量中加以利用? 我想得到一个关键的报章,并在一页上透露一个与这一关键权利相联系的照片。 我还希望以A-Z和“......”为目标。

感谢!

最佳回答

借助 j,你可以使用<条码>关键活动,然后将特性转换为一种扼杀,并符合你的标准。

http://jsfiddle.net/uMjA/1/“working example:

$(document).keypress(function(e)
{
    var s = String.fromCharCode(e.which);
    if (s.match(/[a-zA-Z.]/))
        console.log(s +   is a match! );
});

<>Update: 在另一个要素中,关键内容只是使用<代码>$(#LearnStart ),见here

问题回答

http://api.jquery.com/keypress/“rel=“nofollow”

avoid having ids preceeding with #. with an input of id LearnStar you can insert a script like this:

$("#LearnStar").live("keypress",function(e)
{
    var s = String.fromCharCode(e.which);
    if (s.match(/[a-zA-Z.]/))
        console.log(s +   is a match! );
});

The live event basically takes care of the fact that if the control is rendered on the page after the script has been loaded.

You can do nifty stuff with this like prevent the user from typing non valid keys by using e.preventDefault() and returning false from the callback function.





相关问题
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.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签