Hello, I am a first-year developer who is developing the web. We are developing using Python Flask framework and Jinja template. Below is the html source code.
...
<body>
<div id="parent_of_display_btn"></div>
<div id="display_title"></div>
...
<input type="text" id="input_title" name="input_title">
...
<Button onclick="Something();"> Recall</Button>
...
<script src="{{url_for('.static', filename='js/custom/custom.js')}}" }" type="text/javascript"></script>
</body>
Below is the code for the custom.js file.
function Something(){
div = document.createElement('div');
div.setAttribute("id", "display_btn");
document.getElementById('parent_of_display_btn').appendChild(div);
...
..
$('#display_btn').off('click');
$('#display_btn').click(function() {
document.getElementById('display_title').innerHTML = document.getElementById('input_title').value;
});
}
If you press the recall button with the source, create a div with the id display_btn and add it as child to parent_of_display_btn. And when you press the created display_btn, you put the text value of input_title in the click function to display the text value in the div with the display_title ID.
However, when you run it, even if you enter input_title, document.getElementById('input_title').Value has a value of null. document.getElementById ('input_title') outside of the click event.When I approach the value, I read the value well, but I can't read it in the click event. Ask them what the cause is and how to solve it.
javascript html jquery
https://jsfiddle.net/mps8e95z/
I checked on jsfiddle and it works as you intended.
There seems to be a possibility that another code is not written here.
576 PHP ssh2_scp_send fails to send files as intended
566 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
873 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
594 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.