'MAC' 카테고리의 다른 글
| Google Calendar Sync iCal (0) | 2009/11/17 |
|---|---|
| Logitech Control Center for Macintosh® OS X (0) | 2009/11/10 |
| Snow Leopard Java 관련 문제들.. (0) | 2009/08/28 |
| Parallels 에서 인터넷 뱅킹 사용. (0) | 2009/02/11 |
| Mac에 weblogic 설치하기.. (0) | 2009/01/07 |
| Google Calendar Sync iCal (0) | 2009/11/17 |
|---|---|
| Logitech Control Center for Macintosh® OS X (0) | 2009/11/10 |
| Snow Leopard Java 관련 문제들.. (0) | 2009/08/28 |
| Parallels 에서 인터넷 뱅킹 사용. (0) | 2009/02/11 |
| Mac에 weblogic 설치하기.. (0) | 2009/01/07 |
Contents |
The jQuery library, and virtually all of its plugins are constrained within the jQuery namespace. As a general rule, "global" objects are stored inside the jQuery namespace as well, so you shouldn't get a clash between jQuery and any other library (like Prototype, MooTools, or YUI).
That said, there is one caveat: By default, jQuery uses "$" as a shortcut for "jQuery"
$-function However, you can override that default by calling jQuery.noConflict() at any point after jQuery and the other library have both loaded. For example:
<html>
<head>
<script src="prototype.js"></script>
<script src="jquery.js"></script>
<script>
jQuery.noConflict();
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
jQuery("div").hide();
});
// Use Prototype with $(...), etc.
$('someid').hide();
</script>
</head>
<body></body>
</html>
This will revert $ back to its original library. You'll still be able to use "jQuery" in the rest of your application.
Additionally, there's another option. If you want to make sure that jQuery won't conflict with another library - but you want the benefit of a short name, you could do something like this:
<html>
<head>
<script src="prototype.js"></script>
<script src="jquery.js"></script>
<script>
var $j = jQuery.noConflict();
// Use jQuery via $j(...)
$j(document).ready(function(){
$j("div").hide();
});
// Use Prototype with $(...), etc.
$('someid').hide();
</script>
</head>
<body></body>
</html>
You can define your own alternate names (e.g. jq, $J, awesomeQuery - anything you want).
Finally, if you don't want to define another alternative to the jQuery name (you really like to use $ and don't care about using another library's $ method), then there's still another solution for you. This is most frequently used in the case where you still want the benefits of really short jQuery code, but don't want to cause conflicts with other libraries.
<html>
<head>
<script src="prototype.js"></script>
<script src="jquery.js"></script>
<script>
jQuery.noConflict();
// Put all your code in your document ready area
jQuery(document).ready(function($){
// Do jQuery stuff using $
$("div").hide();
});
// Use Prototype with $(...), etc.
$('someid').hide();
</script>
</head>
<body></body>
</html>
This is probably the ideal solution for most of your code, considering that there'll be less code that you'll have to change, in order to achieve complete compatibility.
Also see: Custom Alias
jQuery before Other Libraries If you include jQuery before other libraries, you may use "jQuery"
when you do some work with jQuery, and the "$" is also the shortcut for
the other library. There is no need for overriding the $-function by calling "jQuery.noConflict()".
<html>
<head>
<script src="jquery.js"></script>
<script src="prototype.js"></script>
<script>
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
jQuery("div").hide();
});
// Use Prototype with $(...), etc.
$('someid').hide();
</script>
</head>
<body></body>
</html>
jQuery If you don't like typing the full "jQuery" all the time, there are some alternative shortcuts:
var $j = jQuery;
$ inside of a block of code without permanently overwriting $:
(function($) { /* some code that uses $ */ })(jQuery)
$ to be Prototype's $, so you're making a choice to use only jQuery in that block.
jQuery(function($) { /* some code that uses $ */ });
| ExtJs xtype List. (0) | 2009/12/23 |
|---|---|
| JQuery 와 다른 라이브러리 충돌시. (0) | 2009/11/12 |
| JQuery 사용팁 모음. (0) | 2009/06/17 |
| Javascript Object Table (0) | 2009/03/18 |
| JQuery 를 이용한 html와 script 와 분리 (0) | 2008/11/13 |
| 팝업창에서 부모 창으로 포커스(Internet Explorer, FireFox) (0) | 2008/11/10 |
| Google Calendar Sync iCal (0) | 2009/11/17 |
|---|---|
| Logitech Control Center for Macintosh® OS X (0) | 2009/11/10 |
| Snow Leopard Java 관련 문제들.. (0) | 2009/08/28 |
| Parallels 에서 인터넷 뱅킹 사용. (0) | 2009/02/11 |
| Mac에 weblogic 설치하기.. (0) | 2009/01/07 |
NodLogin 10c 입니다.
| Ultraeditor 15.20.0.1022 (0) | 2009/12/29 |
|---|---|
| Nodlogin 10c (0) | 2009/11/10 |
| Microsoft Security Essentials (0) | 2009/10/09 |
| RD Tab 2.1.21 (0) | 2009/10/07 |
| WinTail 3.4 (6) | 2009/09/22 |
| Microsoft Office for Mac SP2 Serial (0) | 2009/09/15 |