-1

I can't find a way to change the string "FIND NOW" into something else. I have tried for hours

<button type="submit" class="qbutton  default" style="">FIND NOW</button>

I tried something like this:

<script>
  document.getElementsbyClassName('.button.qbutton.default').innerHTML('change it!');
</script>

Could someone help please?

Pete
  • 57,112
  • 28
  • 117
  • 166
  • 3
    Go read up on how getElementsbyClassName works … it returns a collection, not a single element, so you have to access one of those elements inside the collection first. – CBroe Jun 14 '18 at 13:22
  • 1
    `document.getElementsByClassName('qbutton default')[0].innerHTML = 'change it!'` read [DOCs](https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName) before posting questions – Satpal Jun 14 '18 at 13:23
  • Also your button in the selector doesn't want a dot before it as you don't have a class of button – Pete Jun 14 '18 at 13:24
  • document.getElementsByClassName('qbutton default')[0].innerHTML="change it"; – Karen Vicknair Jun 14 '18 at 13:36

1 Answers1

1

Use document.querySelector('button.qbutton.default') as querySelector() will allow you to select the particular element based on the selector and not list of elements. Also you need to use button as selector and not .button and make sure the script is after the body element to get the HTML rendered properly first.

document.querySelector('button.qbutton.default').innerHTML = 'change it!';
<button type="submit" class="qbutton  default" style="">FIND NOW</button>
Ankit Agarwal
  • 30,378
  • 5
  • 37
  • 62