Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  129] [ 4]  / answers: 1 / hits: 5334  / 10 Years ago, tue, march 4, 2014, 12:00:00

I want to create a simple custom tooltip plugin for jQuery that for every element that has a data-custom-tooltipset. So, something like :



<a href= . . .  data-custom-tooltip=This is my tooltip Text>Hhahaha</a>


OR



<button data-custom-tooltip=This is my tooltip for the button Tex>Haha Button :) </button >


So, the function to display the tooltip would be triggered only if the data-custom-tooltip is NOT empty.



Close enough to this : jQuery selectors on custom data attributes using HTML5


More From » jquery

 Answers
5

You can use :not() selector and remove the empty ones



$('[data-custom-tooltip]:not([data-custom-tooltip=])')


or



$('[data-custom-tooltip]').not('[data-custom-tooltip=]')





or based on what @VisioN said in the comments with the Not Equal Selector



var xxx = $('[data-custom-tooltip][data-custom-tooltip!=]');

[#47175] Monday, March 3, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kristineterrak

Total Points: 74
Total Questions: 109
Total Answers: 115

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;