Javascript newbie here, just trying to tweak this bit of code. It checks for all HTML elements with a title attribute and adds the class ‘tooltipParent’.
I’d like it to only add the class to elements with a title attribute AND the class ‘tooltip’. I think I need to add something to the for loop to check for this extra class?
// loop through all objects with a title attribute
var titles=$('[title]');
// use an efficient for loop as there may be a lot to cycle through
for(var i=titles.length-1;i>-1;i--){
// titled object must be position:relative
$(titles[i]).addClass('tooltipParent');
}
Thanks!
You can put the class requirement into your original selector:
This means
*).tooltip)[title])tooltipParent