Question: I am having problems when I call this code in my webpage:

```
<?php $chat->printChat(); ?>

```

This line of code calls the chatroom ( phpfreechat ) that uses prototype.js 1.6.0.2
After I call this, my jQuery.js stops working. But when I call my jQuery.js after the calling of chat the jQuery works but the Chat doesnt seem to work. How can I make both of this javascript work in my webpage? tnx for the help.

Answer: 
use `jQuery.noConflict()` because you are using `prototype` so that is conflicting with `jQuery`.

> 
> **Description:** Relinquish jQuery's control of the `$` variable.
> 
> 
> Many JavaScript libraries use `$` as a function or variable name, just as `jQuery` does. In `jQuery's` case, `$` is just an alias for `jQuery`, so all functionality is available without using `$`. If you need to use another JavaScript library alongside `jQuery`, return control of `$` back to the other library with a call to `$.noConflict()`. Old references of `$` are saved during `jQuery` initialization; `noConflict()` simply restores them.
> 
> 
> 

### **[Read More](http://api.jquery.com/jQuery.noConflict/)**

**Example**

```
jQuery.noConflict();

// Use jQuery via jQuery(...)
jQuery(document).ready(function()
{
    jQuery("div").hide();
});

```

**OR**

```
var $jQ = jQuery.noConflict();

// Use jQuery via $jQ(...)
$jQ(document).ready(function()

{
    $jQ("div").hide();
});

```

Use the following technique, which allows us to use `$` inside of a block of code without overwriting `$`:

```
(function($) { /* some code that uses $ */ })(jQuery) 

```
Best way is to wrap your all jQuery code inside self executing function in which jQuery is passed as argument.

```
(function ($) {

  // Your jQuery code which can safely use `$`
  ..
  ..

}(jQuery));

```

You can also use,

```
jQuery(document).ready(function($) {
  ...

  //Your jQuery code with which can safely use `$`
  ..

});

```