开发者

How to use an keyword instead of $ in jquery?

I would like to modify my jQuery to not use $ because using the $ sy开发者_如何转开发mbol would break other JavaScript libraries (eg. Prototype, Scripaculous). How can I use another variable name instead of the $ symbol?


Use jQuery.noConflict() for compatibility with other libraries, for example:

var $j = jQuery.noConflict();

Then use $j for jQuery, instead of $...or just use jQuery, in which case you don't need to set a variable.

Note: be sure to include jQuery after the other library, so it knows what to give $ back to.


I believe you're looking for noConflict mode


use this

<script type="text/javascript">
var jq=jQuery.noConflict();
jq(document).ready(function(){
  // your code
});
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜