Reputation: 538
I want to change to text from a button that is dynamically created by JS. I know how to bind a click event on the button, but don't know how to change the text when the page is loaded.
The html code of the button (this is dynamically created by a wordpress plugin).
<a href="#" class="btn loadMoreBtn" id="loadMored">Load more</a>
jQuery code:
jQuery('#loadMored').text('Toon meer producten');
Upvotes: 0
Views: 174
Reputation: 611
Your button isn't actually a button but an anchor. To change the text inside it you would do $("#loadMored").html("Toon meer producten");
.
Upvotes: 0
Reputation: 48
You just need to load script after elements are rendered. In document.ready
for example or in the bottom of your HTML code.
Upvotes: 1