I have a loader on my page and its html looks like this:
<div class="pace-progress" data-progress-text="Loading 50/100" data-progress="50" style="transform: translate3d(100%, 0px, 0px);">
I want to write a JS that can change the data-progress-text when the data-progress is 50
from "Loading 50 / 100"
to "Almost there!".
I do not know where to start and any help would be greatly appreciated.
if ( $('.pace-progress').attr('data-progress-text') == '50' ) {
(".pace-progress").attr("data-progress-text") == "Almost there!"}
==is for comparing a value=is for assigning a valueThat said, since you are using the jQuery
attrmethod you cannot assign a value like that. The method itself accepts a second argument to determine if it is a getter or a setter.The jQuery docs are pretty complete and you should definitely make use of them before asking questions