-6

Trying to replace some text wrapped in a button tag, but this jquery doesn't seem to work for me. Any suggestions?

<div id="memorabilia">
  <button class="btn btn-primary" id="load">More Memorabilia</button>
</div>
$('#load').text(function() {
  $(this).text('MÉG TÖBB MEMORABILIA');
})

https://jsfiddle.net/nqfz5340/2/

1 Answers1

3

You need to import jQuery first. Place your code inside a method like .ready or .click that will trigger the event.

jQuery(document).ready(function(){
    jQuery('#load').text(function() {
        jQuery(this).text('MÉG TÖBB MEMORABILIA');
    })

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


<div id="memorabilia">
<button class="btn btn-primary" id="load">More Memorabilia</button>
</div>

EDIT:

You can ommit the second line. So the final code will be

jQuery(document).ready(function(){
        jQuery('#load').text('MÉG TÖBB MEMORABILIA');
});
Tibs
  • 735
  • 5
  • 16