I’m trying to add an attribute to an element with jQuery; since my markup is created on-the-fly I can’t directly add the attribute. Why is the below script not adding the attribute? Why is this fiddle not functioning as desired? Here is the fiddle I am trying to get working with some sample markup included.
// set the tooltip content
jQuery('li#menu-item-75 a:hover:before').prop('tooltipText', 'w00t');
jQuery('li#menu-item-75 a:hover:after').prop('tooltipText', 'w00t');
You’ll have to set the data attribute with
.attr()in order for the DOM attribute to actually be affected::hoverand:before/:afterdon’t work with jQuery selectors.Demo: http://jsfiddle.net/fkdh8/13/