English 中文(简体)
页: 1 暂停执行直至发出活动
原标题:jQuery halt execution until an event is dispatched

Ok, so I trying to achieve a console-like behavior and I need to pause the execution until some event is dispatched, what I exactly need is this:

var evt = $("element").waitForKeyDown();

这一假设功能应当暂停执行,直到用户发布关于“要素”要素的钥匙,该要素被假定为一个文本领域。 然后,当用户对文本领域的任何关键人物施加压力时,就应继续执行,并且应当载有与该事件有关的信息。

Is this possible to achieve in javascript? or a close behavior that works like.

问题回答

You don t ever want to wait in JavaScript--there s only one thread, and you need it available to handle other events that may be coming in to other parts of the page.

相反,你想要做的是,在你想要等待并把它列入<条码>功能({><>>>>/代码”之后,会发生的一切。 (这一功能称为“连续”,你在整个贾瓦文和其他非常恶劣的环境中都遇到这种模式。)

从那里,请你使用以下格乌拉:

var evt = $("element").keydown(function(event){
   var keypressed = event.keyCode;

   // do whatever you d like with the keypress.
});

你们可以考虑使用,而不是关键词,但关键词(几乎自相矛盾的是)却不给你们所有关键词,而只是那些变成某种文本投入的要闻。

我担心,除了警戒和迅速行动外,没有阻止 j。 这样做的唯一途径是(可能是错误的):

var evt = $("element").on("click",function(){
  //Continue here
});

公正利用关键倒闭事件。 这确实是你想要实现的:只有在关键人物受到压力时才采取行动。





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

热门标签