Jquery plugin working in JSfiidle and not in my page

♀尐吖头ヾ 提交于 2019-12-25 18:25:26

问题


There is something i am missing on this jquery plugin which works in jsfiddle and not in my page.

This is a Jquery plugin for cash Register effect. Look here and you can see this effect on the number below VALOR LIQUIDATIVO.

I have pasted the same code in my page, but the plugin is not working. There is probably an issue about the option to run the script code "onload" as i have seen in this thread but i am not figuring out the problem. How i have to modify the file for my browser?


回答1:


Your problem appears to be a syntax error. Usually javascript will break if a syntax error is found, and although I don't really have any way to test if this is the case, I believe this to be your problem.

As I said in the comments, when copying data from jsfiddle to an actual script, it tends to copy in invisible characters that can break things, due to the way jsfiddle formats text.

When I copied your code, from your webpage, into Notepad++(a code editor), I found a hidden character directly after your function call, on line 347. This of course showed up as a question mark, like so:

$(document).ready(function() {

    $('#valorliquidativo').cashRegister();

});​
  ^ hidden character directly after this semi-colon

Chrome's javascript console says the above is an illegal character, so delete that line, type it out manually, and try again. See if it works.




回答2:


This is the result of the copy and paste from jsfiddle in my notepad++

$(document).ready(function() {
    $('#valorliquidativo').cashRegister();
});? //<---

Notice the ?, it's being pasted with the code block and made the error appear. try to delete the empty line in your code block using backspace or manually write this code block.



来源:https://stackoverflow.com/questions/12560637/jquery-plugin-working-in-jsfiidle-and-not-in-my-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!