Search for a specified value within an array and return its index (or -1 if not found).

The $.inArray() method is similar to JavaScript’s native .indexOf() method in that it returns -1 when it doesn’t find a match. If the first element within the array matches value$.inArray() returns 0.

You Might Not Need JQuery


$.getJSON('/my/url', function(data) {



var request = new XMLHttpRequest();
request.open('GET', '/my/url', true);

request.onload = function() {
if (request.status >= 200 && request.status < 400) {
// Success!
var data = JSON.parse(request.responseText);
} else {
// We reached our target server, but it returned an error


request.onerror = function() {
// There was a connection error of some sort


How to check if an element is hidden in jQuery?

It is possible to toggle the visibility of an element, using the functions .hide(), .show() or .toggle().

How would you test if an element is visible or hidden?

// Checks for display:[none|block], ignores visible:[true|false]

Example of using the visible check for adblocker is activated:

    $("#ablockermsg").text("Please disable adblocker.").show();