jQuery DOM 数组作为参数
我正在处理一些 HTML 页面,并且需要添加一些工具提示。由于条件限制,我选择了一个名为qtip的Jquery插件。我确实不太擅长 JavaScript,但我设法做了一些看起来像附图的事情。 (编辑:无法添加图片 - 抱歉。但看起来不错!;)
对于工具提示内容,您可以直接将 html 作为参数。但在文档中,它说
您还可以传递 jQuery DOM 数组 作为参数
(参见相关页面)
出于多种原因,我真的很想使用此选项。 我在网上搜索了一下,但找不到如何传递这个所谓的 jQuery DOM 数组 作为参数。
代码如下所示:
$('a[class="someClass"]').qtip({
content: 'my content here',
show: 'click',
hide: 'click',
(+ other arguments...)
});
我的问题:jQuery DOM 数组 到底是什么以及如何将它作为内容参数?
我确信答案就在网络上,但我已经花了相当长的时间来寻找它,而且我真的负担不起仅仅为了这些工具提示就花 3 天学习 JavaScrip...
非常感谢。
I'm working on some HTML pages, and I needed to add some tooltips. Because of the constraints, I chose a Jquery plugin named qtip. I really ain't that good with JavaScript, but I managed to do something that look like the attached picture. (edit : cannot add picture - sorry. But it looks fine ! ;)
For the tooltip content, you can directly put html as the argument. But in the documentation, it says
You can also pass a jQuery DOM array as the argument
For several reasons, I'd really like to use this option.
I've searched the net a bit, but couldn't find how to pass this so called jQuery DOM array as the argument.
Code looks like this :
$('a[class="someClass"]').qtip({
content: 'my content here',
show: 'click',
hide: 'click',
(+ other arguments...)
});
My question : what exactly is a jQuery DOM array and how do I put it as the content argument ?
I'm sure the answer is on the web, but I already lost quite some time looking for it, and I can't really afford to spend 3 days learning JavaScrip just for these tooltips...
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我也不确定 jQuery DOM 数组应该是什么,但我认为它们的意思是,您可以使用 jQuery 对象作为内容。
编辑
实际上,从我之前的示例开始,尝试一下上面的示例是否有效。我猜
$(this).attr('alt')
是一个坏例子,因为它无论如何都会返回一个字符串。I'm not sure what a jQuery DOM array is supposed to be either, but I think what they mean, is that you can use a jQuery object for the content.
EDIT
Actually, scratch my earlier example and try if something like the example above works. I'm guessing that
$(this).attr('alt')
is a bad example, since it anyways returns a string.嗯,它说:
如果没有测试,我会冒险猜测,如果您传递这样的内容:
所有具有类
addme
的元素都将被附加到工具提示中,例如,如果您有以下内容:“HelloWorld”将被附加到工具提示内容中。
Well, it says:
Without testing I would risk a guess and if you pass such thing:
All elements with class
addme
will be appened to the tooltip, for example if you have this:"HelloWorld" will be appended to the tooltip contents.