Lalit Hira
Lalit Hira

Reputation: 31

Change jQuery $ function

I want to change the accessibility parameter of jQuery which is $ usually for access the jQuery we use.

$.document....Bla.Bla...

but i want to access this $ variable something like this

NI.$.document......

Help me to solve this problem.

But i don't want to use something like this..

var my_Js=$.noConflict(true);

Upvotes: 1

Views: 60

Answers (2)

Shubham Khatri
Shubham Khatri

Reputation: 281794

Make use of jQuery.noConflict(true); and then assign that to the object that you want to use

var NI$ = $.noConflict(true);

NI$(document).ready(function(){})

var NI$ = $.noConflict(true);

NI$(document).ready(function(){
  alert('HEllo');
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="app">Hello</div>

Upvotes: 1

Raj
Raj

Reputation: 321

You can try using

(function(my_Js){

    my_Js(function(){

       alert('my_Js is safe!');

    });

})(jQuery)

Upvotes: 1

Related Questions