-1

how do I search by ID and change "data-totalReplies" value?

<div id="newReply" data-totalReplies="'.mysql_num_rows($replyQuery).'"></div>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Roi
  • 47
  • 1
  • 7
  • A simple Google turns up many duplicates, did you check them? [Example 1](https://stackoverflow.com/questions/13524107/how-to-set-data-attributes-in-html-elements), [example 2](https://stackoverflow.com/questions/7874320/updating-the-value-of-data-attribute-using-jquery), [example 3](https://stackoverflow.com/questions/14935191/adding-data-attribute-to-dom), etc ... – Don't Panic Jan 21 '18 at 11:31

1 Answers1

1

The data attributes are also a generic attributes of the HTML tags. So it can easily be alter with the generic attr() as follows:

 $('#newreply').attr('data-totalReplies','new_values');
Md Monjur Ul Hasan
  • 1,705
  • 1
  • 13
  • 36