jQuery $(this) keyword

When you perform an DOM query through jQuery like $(‘class-name’) it actively searched the DOM for that element and returns that element with all the jQuery prototype methods attached. When you’re within the jQuery chain or event you don’t have to rerun the DOM query you can use the context $(this). Like so: $(this) will … Read more

What does [object Object] mean? (JavaScript)

It means you are alerting an instance of an object. When alerting the object, toString() is called on the object, and the default implementation returns [object Object]. If you want to inspect the object, you should either console.log it, JSON.stringify() it, or enumerate over it’s properties and inspect them individually using for in.

How do I link a JavaScript file to a HTML file?

First you need to download JQuery library from http://jquery.com/ then load the jquery library the following way within your html head tags then you can test whether the jquery is working by coding your jquery code after the jquery loading script If you want to use your jquery scripts file seperately you must define the external .js … Read more

Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?

If I understood it right you are doing an XMLHttpRequest to a different domain than your page is on. So the browser is blocking it as it usually allows a request in the same origin for security reasons. You need to do something different when you want to do a cross-domain request. A tutorial about … Read more

JavaScript sleep/wait before continuing [duplicate]

JS does not have a sleep function, it has setTimeout() or setInterval() functions. If you can move the code that you need to run after the pause into the setTimeout() callback, you can do something like this: see example here : http://jsfiddle.net/9LZQp/ This won’t halt the execution of your script, but due to the fact that setTimeout() is an asynchronous function, this code will … Read more