我想更新与jquery 1.4.1配合使用的代码,以便与jquery 1.10.2一起使用。
我在谷歌搜索,但我没有找到我必须做出的改变。
我收到以下错误:
Uncaught TypeError: Object #<Object> has no method 'photoTagger'
这是我想要更新的功能的名称。
答案 0 :(得分:2)
如果没有必要,我建议你不要更改整个代码,因为许多代码依赖于jQuery库,而且某些函数也弃用,不支持最新版本。您可以在同一页面上使用多个jQuery文件。
<!-- load jQuery version 1.4.1 -->
<script src="jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
var $jQuery1_4 = $.noConflict(true);// Here you must need to pass true
//else it will only free $ variable
//and using jQuery with blow libraries
//cause conflict
</script>
//you must load second library later after initializing
//first instance of version and freeup jQuery keyword
//else jQuery keyword will
//cause conflict it you uplaoded both files.
<!-- load jQuery version 1.10.0 -->
<script src="jquery-1.10.0.js" type="text/javascript"></script>
<script type="text/javascript">
var $jQuery1_10 = $.noConflict(true);
</script>
//so now here $ and jQuery both cannot be used
//using $jQuery1_10 will call version 1.10.0 library code
$jQuery1_10( "div p" ).show();
//using $jQuery1_9 will call version 1.4.1 library code
$jQuery1_4( "div p" ).show();
答案 1 :(得分:2)
您应该只使用jQuery迁移文件,可在此处找到: http://code.jquery.com/
然后,您可以使用最新的jQuery版本,旧的插件/ jQuery代码仍然有效,例如:
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
答案 2 :(得分:0)
在这种情况下,问题不在于jquery verisons之间的不兼容性,而是加载javascript和jquery文件以及调用函数的错误顺序。 我解决了问题,你的答案对我有帮助。谢谢你的帮助!