We help IT Professionals succeed at work.
Get Started

Set innerHTML of Span in Modal

Daniel Pineault
Last Modified: 2018-09-25
I'm trying to open a modal and then set the innerHTML of a span, but can't seem to get it working.

The modal is

            //'header'=>'<h4>Add a New Company</h4>',
            //'headerOptions' => ['id' => 'modalHeader'],
            'header' => '<span id="modalHeaderTitle"></span>',
            'headerOptions' => ['id' => 'modalHeader'],
            'closeButton' => [
                'class'=>'btn btn-warning pull-right',
            'clientOptions' => [
                'backdrop' => 'static', //true,
                'keyboard' => false, // true,
        echo '  <div id="modal-system-messages" style="opacity: 1; display: none"></div>';
        echo "<div id='modalContent'></div>";

Open in new window

And then my js for the calling button is

        function (){
            //Open the modal window
			// Set the modal title span
			// alert($(this).attr('title'));
			$('#modalPopup #modalHeader #modalHeaderTitle').innerhtml = '<h4>' + $(this).attr('title') + '</h4>';

Open in new window

I have validated that alert($(this).attr('title')); is returning the proper value but the .innerHTML line does nothing.

Thank you for your help.
Watch Question
Distinguished Expert 2020
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE