javascript - Modal with Changing Content -


i making modal in file named modal.html , content populate modal external js file. content string returned following function in js file named one.js:

function current() {   if(selection === 0 && yesresources[questionscounter] != null)   {     return yesresources[questionscounter];   }   else if(selection === 1 && noresources[questionscounter] != null)   {   return noresources[questionscounter];   }   else   {     return 'you on right track!';   } } 

the html code written modal follows:

<!-- modal --> <div id="mymodal" class="modal">      <!-- modal content -->     <div class="modal-content">         <div class="modal-header">            <span class="close">&times;</span>            <h2>resources</h2>         </div>     <div class="modal-body">         <p>test</p>         <p id='modalcontent'></p>     </div>     <div class="modal-footer">         <h3>living progress</h3>     </div>   </div> </div> 

i call current() function populate paragraph space id 'modalcontent'. i've tried using document.getelementbyid("modalcontent").innerhtml = current(), document.getelementbyid("modalcontent").textcontent = current(), calling function between paragraph tags, etc. other suggestions? thanks.

you forgot id name when typed document.getelementbyid(), , suggest use document.queryselector('#modalcontent'), because way can applied selecting classname or tagname.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -