开发者

How to use an keyword instead of $ in jquery?

开发者 https://www.devze.com 2023-01-30 11:19 出处:网络
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 inst

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

精彩评论

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