Array of jQuery DOM as an argument

I am working on some HTML pages and I need to add hints. Due to limitations, I chose a jQuery plugin called qtip. I'm really not that good with JavaScript, but I managed to do something similar to the attached picture. (editing: unable to add image - sorry, but it looks great !;)

For the contents of the tooltip, you can directly put html as an argument. But the documentation says:

You can also pass a jQuery DOM array as an argument

( see the corresponding page )

For several reasons, I would really like to use this option. I searched the net a bit, but could not find how to pass this so-called jQuery DOM array as an argument.

The code is as follows:

$('a[class="someClass"]').qtip({ content: 'my content here', show: 'click', hide: 'click', (+ other arguments...) }); 

My question is: what is a jQuery DOM array and how to put it as a content argument?

I am sure that the answer is on the Internet, but I have been looking for it for quite some time, and I can not afford to spend 3 days learning JavaScrip just for these tooltips ...

Thank you very much.

+4
source share
2 answers

I'm not sure what the JQuery DOM array should be, but I think that means you can use the jQuery object for the content.

 content: $('#menu li:first') 

EDIT

Actually, scratch my previous example and try if something like the example above works. I assume $(this).attr('alt') is a bad example, since it anyways returns a string.

+3
source

Well, he says:

You can also pass a jQuery DOM array as an argument that will clone links and add them to the contents of the tooltip.

Without testing, I would venture to guess, and if you pass such a thing:

 $('a[class="someClass"]').qtip({ content: $(".addme"), show: 'click', ... 

All elements with the addme class will be attached to the tooltip, for example, if you have this:

 <span class="addme">Hello</span> <span class="addme">World</span> 

"HelloWorld" will be added to the tooltip content.

+1
source

Source: https://habr.com/ru/post/1336312/


All Articles