<script>
function show_button2(){
$('#demo') .html('<button>Button2</button>');
}
</script>
<button onclick="show_button2();">Button1</button>
<divid='demo'></div>
I'd like you to click 'Button1' and get 'Button 2' (in <div>
of id='demo'
below).
But with the code above, when I click 'Button1' nothing comes out.
According to the code above, why is the jQuery selector ($('#demo')
) ineffective?
How do I resolve this issue?
javascript jquery
As BLUEPIXY said in the comments, there is a possibility that jQuery is not loaded.
Below is the same code as the questionnaire, but it works.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
function show_button2(){
$('#demo') .html('<button>Button2</button>');
}
</script>
<button onclick="show_button2();">Button1</button>
<divid='demo'></div>
567 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
577 PHP ssh2_scp_send fails to send files as intended
606 Uncaught (inpromise) Error on Electron: An object could not be cloned
597 GDB gets version error when attempting to debug with the Presense SDK (IDE)
884 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.