user3387046
user3387046

Reputation: 465

Changing bootstrap panel title with js

I'm trying to change the panel title when a button is clicked.

I've tried to assign an id to the panel-title but it seems a wrong approach

                    <div class="panel-heading">
                        <h4 id="something" class="panel-title">Engagement Indicators Average</h4>
                    </div>

                   document.getElementById('something').innerHTML = 'New title';  

Upvotes: 0

Views: 295

Answers (1)

Leandro Andrade
Leandro Andrade

Reputation: 115

document.getElementById('btn_change').addEventListener('click', function() {
  document.getElementById('something').innerHTML = 'New title';
});
<div class="panel-heading">
  <h4 id="something" class="panel-title">Engagement Indicators Average</h4>
</div>
<button id="btn_change">
Change my title
</button>

Use the snippet above as a guide. It works.

Upvotes: 1

Related Questions