English 中文(简体)
j 标注。
原标题:jQuery while object.hasClass

我试图找到某种办法,在某个时候停止某项职能,直到某个时候不再有特定类别。 我不能改变这一类别被分配和删除的地方,因为它是一片gin。

我正在考虑这样做。

function DoSomething() {
        while ($( div.divControl ).hasClass( playing ))
        {
            //Wait here
        }
    };

这是正确的道路吗?

最佳回答

This will block so the element will never be changed, as no other code will execute. What you need to use is an interval:

var interval = setInterval(DoSomething, 500);

function DoSomething() {
        if ($( div.divControl ).hasClass( playing ))
        {
            // Do something
            clearInterval(interval);
        }
    };

这将每半年执行一次职能。 间隔期将在职能成功后取消。

问题回答

更不用说,这只会使浏览器陷入无限的循环。

您的最好礼仪(因为我可以随时思考),就是对这项职能进行规定,并检查你们的遗体是否仍然拥有第二季度的班级。

但是,根本不是冰,吗?





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

热门标签