Why does my jsfiddle work but not my web site? [cl

2019-01-26 02:26发布

问题:

I'm not sure what im missing here

I have the following JS fiddle:

http://jsfiddle.net/thetylercox/eeMva/3/

And the site:

http://soldbybillcox.com/treasure/demo1.html

I'm not sure what I am missing but my website does not work.

回答1:

​ from copying and pasting from fiddle



回答2:

Just before your closing </script> tag, you've got an illegal character. Try right-clicking and 'view-source' in Chrome. You'll see it. Line #68.



回答3:

On the line 68 you have illegial symbols right after a closing bracket }.

Remove it and the code should work.



回答4:

Open up your console, it says: Uncaught SyntaxError: Unexpected token ILLEGAL, demo.php:68

    ...
    var total1 = document.getElementById("total1").value = total;

}​

These might be caused by a BOM if you're using different files/includes to generate the output. Otherwise, it might just be some copy/paste error. Just remove the }​</script> to make sure the 'invisible' chars are gone between } and < and then type }</script> again and be done with it.



回答5:

Seems to work just fine, except you have a random trio of symbols at the end of your <script>, so remove those and it should be just fine.