Hi I have a html that is generated by a JavaScript. I also have another separate JavaScript that suppose to hide and do other things to that html. The problem is that html is not responding to any of the other javascript's functions or methods.
I tried including Javascript within that Javascipt but that doesn't seem to work
HTML
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.1.min.js"></script>
<script src = "js/java1.js"type="text/javascript"></script>
<script src = "js/java2.js"type="text/javascript"></script>
</head>
<body id = "example">
</body>
Javascript1
function creatething(){
var html ='';
html += '<div id = "button">Button <div id = "hide"> EXAMPLE </div> </div>'
return html;
}
function insertHTML(id, html) {
var el = document.getElementById(id);
if(!el) {
alert('Element with id ' + id + ' not found.');
}
el.innerHTML = html;
}
function run() {
var html = creatething();
insertHTML('example', html);
}
window.onload = run;
Javascript2
$(document).ready(function() {
$('#hide').hide();
});
java2.jsappears to depend on a library, such a jQuery. The HTML will need to include this dependency as well.window.onloadprobably runs after the$(document).ready(...)callback.hide()does the element actually exist at that time? "JavaScript 1" seems like a really round-about way to add static markup to the page. Seems like you can just... add the markup to the page instead.