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
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>
Because the $ is already used in previous reference... I suspect abc was defined something like this:
var abc = $('#abc')
So the $ is already referenced...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.