I’m not too sure why my code is causing this.
I have this jquery script in the header:
<script>
$(document).ready(function() {
$('.control').on('click', function(e) {
e.preventDefault();
var field = $(this).data('field');
$('.hider:visible').fadeOut("slow", function() {
$('#' + field + '-gallery, #' + field + '-tag').fadeIn("slow");
});
});
var randomIndex = Math.floor((Math.random() * 100) + 1) % 3;
console.log(randomIndex);
var field = $($('a').get(randomIndex)).data('field');
$('#' + field + '-gallery, #' + field + '-tag').fadeIn("slow");
})â;
</script>
when I reload the page, nothing happens so it appears the script isn’t running. When I inspect the page on Chrome, I see there is this error which is in a tab called (program) and it’s in the first few lines line:
if (window.top.require) {
Uncaught SyntaxError: Unexpected token ILLEGAL
window.top.require("ripple/bootstrap").inject(window, document);}
I don’t know what it is in my code to cause this error. When I take out my script, it goes away. Not too sure if it’s something with wordpress or jqueryUI (I have that loaded for another plugin).
You have an illegal invisible character on the last line between the
)
and the;
.Place your cursor after the
;
, and start backspacing until you delete the)
, then retype them both.You’ll notice that while backspacing, the cursor will fail to move one time. That’s when the invisible character is being deleted.
This happens when copy/pasting code from jsFiddle or perhaps other similar sites.
The character is the unicode
u200B
.AFAIK, the script code you don’t know where it comes from, is generated by the Blackberry emulator Ripple, when it inserts a generated script your document.documentElement (see at GitHub). I have seen this behavior causing problems in many of my projects, for example, being inserted on ajax results with dataType HTML and confusing my selectors, or getting my ajax responses dirtier in combination with jquery form plugin (can’t link to it because of not enough reputation), etc. I think it might be interferring with your javascript? Hope it helps.