Forum Replies Created
Hmm.. that code is a bit tricky to read at the moment. :) I think I understand what you aim to do though. Could you post an example of how the HTML looks? I suspect that you are making the solution more complicated than it needs to be.
If you’re using jQuery, then have a look if one of these might do the trick:
Where is that JS located, I assume it is not just floating above the HTML like that? Is it even inside a
<script>tag? Included somewhere? When is the JS executed, could it be executing before the HTML exists?
On test-modal.html: jQuery is included AFTER a bunch of other jQuery-dependent plugins, which causes a whole bunch of errors. I would start there. Include jQ before the plugins.
On test-loading.html: The dollar variable (
$) is used by some other function and is not used by jQuery, so no jQuery stuff that you do with $ will work there. If you want to use $ instead of using its alias,
jQuery, you can achive it quite easily. If all you need is to do stuff at document ready, then replace this:
Now you have passed jQuery to that scope as $ and it will not interfere with that other $ function.
I don’t know how much control you have over all the other code on that site, but one solution would be to find that weird function that has hijacked the $ variable and call it something else, but then you need to fix all calls to that function to be sure that you don’t break stuff in other places.
First of all, when you say “version of js” you really mean “version of jq, or jQuery”. jQuery is built on JS but it’s weird to say “version of js” because that’s a whole other deal. But, maybe it was just a typo. :)
Yep, the jQuery dollar variable ($) is undefined on your site. Taking a closer look, it seems that the jQuery script that you have included is not identical to the one on, for example,
Look at the very bottom of your jQuery file
http://marensblog.dk/wp-includes/js/jquery/jquery.jsThat last line that says
Did you add this line? It is what’s causing these errors, because it tells jQuery to “forget” about the $ variable by setting it to whatever value it had before jQuery was loaded, in your case undefined.
Long story short: Remove that last line from your jquery.js file.
You mean something like this?
document.getElementById("test").innerText = 'Whatever';
Or, if you need to add some HTML to that value:
document.getElementById("test").innerHTML = 'Whatever makes you <em>happy</em>';