I'm trying to make a jQuery (or even a Javascript) function with a function using $("script").append(
, but once it is made the "page" or "doc" has already loaded and so doesn't "see" it. (the function wasn't there when it loaded so to the page it "doesn't exist", even though it IS created and viewable). Is there ANY way to reload the <script>
or "re-document.ready" the jQuery so the page knows that it NOW exists.
I know it's the document.ready
loading process because if I hard code the functions it works just fine (because it exists before the page loads). Somebody HAS to know how to do this or how to work around it. How do you use $("script").append(
?
This is an example of what I'm trying to do.
function makeFunction(array){
$("script").append("$(document).ready(function({$('#"+array+"').on('click', function(){$('#"+array+"').hide();});});");
}
This function is called within another function that runs through a loop. The looping function is being called directly after the <script>
tag. That way (to my understanding) it loads with the document.ready
. The problem is that then the newly created functions are never made "ready" by the initial document.ready
loading (because again, they didn't existed yet).
So I'm asking if there is a way to work around this so I can have a singular function write my many functions for me.
If I missing any vital information please be specific as to what "context" is needed.