Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify value of attribute

How to modify the value of data-tooltip? I would like to do that with one line of code.

Here is the element:

<li class="ui-btn-icon-left " data-icon="cf">
  <a href="#" class="ui-btn ui-icon-cf">
    <span class="tooltip" data-tooltip="NeverGiveUp">Samaras</span>
  </a>
</li>

Here are two of my attempts:

$($(li).find('a').find('span').attr('data-tooltip')).val('foo');
$($(li).find('a').find('span').attr('data-tooltip')).text('foo');

which had no impact.

like image 620
gsamaras Avatar asked Jan 25 '26 17:01

gsamaras


1 Answers

The shortest notation would be:

$('li a span').data('tooltip', 'foo');
like image 132
MaxZoom Avatar answered Jan 28 '26 06:01

MaxZoom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!