I have a question. Good. I have a post in which users post comments and next to each post I have a button belonging to each one of them. get a popup.
With what event? One event for several elements. But let it be the same for all those buttons.
ahhh. Those buttons are generated or printed with php, when the user posts something, that something has a button. Help!!!
Given your comments and your confirmation of it, what you want to do is the following:
This can be done very easily using classes or attributes on elements. Here are two ways:
Tooltip on click
For this we are going to use attributes
data-
that I find more useful than classes in cases like these. What we will do is the following:data-tooltip
display a tooltip when you click on them. For this, it is necessary to use the pseudoselectorsbefore
andafter
.Tooltip on hover (no JS required)
For this version we remove the
tooltip-visible
and replace it withhover
to get the same effect.Update
I see you have edited your question again. I hope this time you said exactly what you want to do. What you want is to display a floating dialog, like a kind of modal. Since you have put the tag
jQuery
, I will give you an answer based on it.What we will do is extend the jQuery prototype.
To use this minilibrary, just do:
Where
extraMargin
is the extra vertical margin that is given to the tooltip, so that there can be the effect of moving vertically.If the button is repeated "x" times but the functionality is the same you can use a class to identify them and with jquery in the click event show the Modal window.