I agree with @Nirazul, if possible, go for a clean css solution.
If you cannot, just remember that you:
- getting value a of attribute li
- replace the link text inside the selected one with its contents
- change operation to handlerOut
So:
$( function() { $("#topnav li").hover( function () { var myLi = $(this); myLi.attr('small', $('a', myLi).text()); $('a', myLi).text(myLi.attr('full')); }, function () { var myLi = $(this); $('a',myLi).text(myLi.attr('small')); } ); });
Updated example .
source share