0

I am using javascript file and jquery.From my javascript file,I am doing like this:

abc.cde.on({

});

which is calling one widget written in jquery.

abc.cde are namespaces in jquery widget file.

Can anyone please tell how abc.cde.on is calling jquery method without using $ sign before abc.cde

2 Answers 2

1

Because cde is already an instance of a jQuery object. You can perfectly store the result of a jQuery selection (or a jQuery widget instance) in an object to reuse it after, see example:

var namespace = {
  obj: $('div'),
};

//then you can do:
namespace.obj.on('click', function(){
  this.style.color = 'red';
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>CLICK ME</div>

Sign up to request clarification or add additional context in comments.

Comments

0

Because the $ is already used in previous reference... I suspect abc was defined something like this:

var abc = $('#abc')

So the $ is already referenced...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.