Node.js document is not defined

document relates to the DOM (Document Object Model) in a web browser. Node.js, however, is not a browser environment. It is a server environment, much like PHP or Perl, and as such, you can’t access the browser’s DOM or do anything specific to browser-hosted JavaScript. The closest you could get is using something like browserify to include Node.js … Read more

What is the meaning of “$” sign in JavaScript

Your snippet of code looks like it’s referencing methods from one of the popular JavaScript libraries (jQuery, ProtoType, mooTools, and so on). There’s nothing mysterious about the use of $ in JavaScript. $ is simply a valid JavaScript identifier. JavaScript allows upper and lower letters, numbers, and $ and _. The $ was intended to be used for machine-generated variables (such as $0001). Prototype, jQuery, … Read more

Add table row in jQuery

The approach you suggest is not guaranteed to give you the result you’re looking for – what if you had a tbody for example: You would end up with the following: I would therefore recommend this approach instead: You can include anything within the after() method as long as it’s valid HTML, including multiple rows as per the example … Read more

Disable same origin policy in Chrome

Close chrome (or chromium) and restart with the –disable-web-security argument. I just tested this and verified that I can access the contents of an iframe with src=”http://google.com” embedded in a page served from “localhost” (tested under chromium 5 / ubuntu). For me the exact command was: Note : Kill all chrome instances before running command The browser … Read more