Hi there, I'm currently trying to make some changes to the textContent of the HTML code below. However, it contains an <i>
tag, so I'm wondering how I can change the textContent without affecting the <i>
tag itself. Is there a way to edit the HTML tag in the script while preserving the <i>
tag's class but only modifying the text within it?
This is what the original HTML looks like:
https://i.sstatic.net/J69Ti.png
And here is what it looks like after my edits:
https://i.sstatic.net/c8SoZ.png
HTML Code
<a id="notificationUnread" class="dropdown-item">
<i class="fas fa-envelope mr-2"></i> 0 unread notifications
</a>
Script
var notificationUnread = document.getElementById('notificationUnread').textContent = "TEST"