问题描述
我正在使用jQuery,并与需要获取选项的jQuery UI进行了一些交互.但是,有可能尚未将jQuery UI函数应用于DOM对象.访问选项时,我现在遇到JavaScript错误.
I'm using jQuery and have some interactions with a jQuery UI where I need to get options. However there's a possibility that the jQuery UI function has not been applied yet to the DOM object. I'm getting a JavaScript error right now when I access an option.
我有一个带有进度条的DOM对象( http://docs.jquery.com/UI/(可能)附加到进度栏).在另一个线程中,我试图使用domObj.progressbar("option", "value")
访问这些选项.
I have a DOM object that has the progressbar (http://docs.jquery.com/UI/Progressbar) attached to it (maybe). In another thread, I'm trying to access the options using domObj.progressbar("option", "value")
.
如何确定domObj
是否已附加progressbar
?
推荐答案
DOM对象将获得一个附加的CSS类:"ui-progressbar".如果您在 http://docs.jquery.com/UI/Progressbar 上查看源代码,那么您可以看到id = progressbar的div,仅此而已,但是如果使用Firebug并单击该元素,则可以看到它添加了更多分类.
The DOM object will get an extra CSS class appended to it: "ui-progressbar". If you View Source on http://docs.jquery.com/UI/Progressbar then you can see a div with id=progressbar and nothing more, but if you use Firebug and click the element you can see it has a few more classed added.
我认为@jamiebarrow的解决方案在这里更正确.
Edited: I think that @jamiebarrow's solution is the more correct one here.
这篇关于需要知道jQuery UI Widget是否已应用于DOM对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!