what’s the typeof(jQuery)

The typeof operator when applied to the jQuery object returns the string "function". Basically that does mean that jQuery is a function.

But the typing sort of stops there. Unlike statically typed languages, the number, order, modes, and types of parameters are not taken into account when computing the type of a a function. In JavaScript, it is just a “function.”

When you create a function in JavaScript, the function object you create is given two properties, length and prototype, and its prototype is set to Function.prototype so it has inherited properties like apply and call.

And as others have already answered, feel free to add your own properties. a function is just an object.

But be careful about “type.” Techncially there are only SIX types in JavaScript: Null, Undefined, Boolean, Number, String, and Object. So the real answer to your question, what is the exact type ofjQuery is …. actually … drumroll …. Object.

Advertisements

difference between document.ready and document.load in jquery

Jquery $(document).ready function event executes a bit earlier than window.onload() and called once the DOM(Document object model) is loaded on your page i.e.(anchor tag, table, div tag, paragraph tag etc..). It will not wait for the images, frames to get fully load. It means that it is the earliest stage in page load process.

 

The ready event occurs after the HTML document has been loaded, while the onload event occurs later, when all content (e.g. images) also has been loaded.

The onload event is a standard event in the DOM, while the ready event is specific to jQuery. The purpose of the ready event is that it should occur as early as possible after the document has loaded, so that code that adds functionality to the elements in the page doesn’t have to wait for all content to load.

How to get the jQuery MaskedInput unmask() function to work properly?

https://code.jquery.com/jquery-latest.min.js
https://igorescobar.github.io/jQuery-Mask-Plugin/js/jquery.mask.min.js
http://cloudfour.github.io/hideShowPassword/hideShowPassword.min.js

<input class="hideshowpwd cep" id="password-2" type="text" placeholder="Password" autocapitalize="off" autocomplete="off" spellcheck="true" style="margin: 0px; padding-right: 41px;">

$(document).ready(function(){
$('.cep').mask('000-00-0000');
$('.hideshowpwd').hidePassword('focus', {
toggle: { className: 'my-toggle' }
});
$('.my-toggle').click(function(){
var mask = "000-00-0000";
if($(this).hasClass('hideShowPassword-toggle-show')){
var unmaskval = $("#password-2").unmask(mask);
$('#password-2').removeClass('cep');
}else{
$("#password-2").mask(mask);
}
});
});

Preventing session expiration with AJAX

var refreshTime = 600000; // every 10 minutes in milliseconds
window.setInterval( function() {
    $.ajax({
        cache: false,
        type: "GET",
        url: "refreshSession.php",
        success: function(data) {
        }
    });
}, refreshTime );

 $(document).ready( function() {
        var refreshTime = 600000; // in milliseconds, so 10 minutes
        window.setInterval( function() {
            var url = 'http://mysite.mydomain/refreshSessionURL';
            $.get( url );
        }, refreshTime );
    });