does (hash) mean anything as a function parameter in javascript?

var newFieldShow = function(hash) { hash.w.fadeIn(“2000”); }; I see this in some code I have retrieved from online. I’ve never seen hash mentioned.. I am trying to determine if it has something to do with hashing, or if it’s just an event reference like function(event) which I’m used to seeing, and curious as to why […]

What does split function look like?

I came across this statement : userName = document.cookie.split(“=”)[1]; after reading about split statement here at w3schools. which says that syntax of split is string.split(separator, limit). Then what does the square bracket after first parens. mean ? If this is true what does split function look like ?

jquery/javascript finding the value within a dynamically created element id

I have a dynamically generated html table whose columns have id assigned dynamically. for ex: <td id=”1″>1</td> <td id=”2″>2</td> …. …. <td id=”n”>n</td> in order to get the get value of a specific column I am using document.getElementById(“#myvar”).innerHTML or $(“td#myvar”).html where myvar is variable that contains search element such as 2 or 3 etc. But […]

Map null values to array

Why isn’t null added to my keys array below? HTML <input type=”radio” data-codekey=”1″/> <input type=”radio” data-codekey=”null”/> JS $(function(){ var keys = $step.find(‘input[type=”radio”]’).map(function (i, el) { return $(el).data(‘codekey’); }).get(); console.log(keys); // [1] //desired result: [1, null] }); http://jsfiddle.net/Mewem/

Closest previous element with certain ID (with prev())?

I have a big div wit a lot of smaller divs within it. Say, <div id=”parent”> <div id=”child1″> </div> <div id=”child1″> </div> <div id=”child2″> </div> <div id=”child1″> </div> <div id=”child1″> </div> </div> If I’m currently at the last ‘child1’, how dow I get to the top most child1 with prev()? For me it breaks when […]

console.log of element.children shows 0 length but has three entries when expanded later

In my javascript, I have two elements. I have logged the two elements and it shows… Element 1. Element 2. There are problem. When I console.log the elements.children they obviously return some HtmlCollections You will understand what the following means in a minute: But the weird thing is, that one HtmlCollection is empty (and has […]

stand-alone lazy loading images (no framework based)

I look after a site which by nature has to load quite a lot of images and content on the page. We have decreased the number of elements and graphical layout images as much as we can, so we are now looking at ways to increase the page load in the browser. Does anyone know […]

Canvas FPS artificially limited to 100fps?

In this page that counts the number of frames rendered and prints the FPS onto the canvas, we can see that it tops out at 100fps, which seems suspicious at the least. Why is this? <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”utf-8″> <title>Canvas FPS artificial limiting</title> </head> <body> <canvas id=”c” width=”320″ height=”240″></canvas> <script> var c […]

Javascript – Regex finding multiple parentheses matches

So currently, my code works for inputs that contain one set of parentheses. var re = /^.*\((.*\)).*$/; var inPar = userIn.replace(re, ‘$1′); …meaning when the user enters the chemical formula Cu(NO3)2, alerting inPar returns NO3) , which I want. However, if Cu(NO3)2(CO2)3 is the input, only CO2) is being returned. I’m not too knowledgable in […]

'this' keyword overriden in JavaScript class when handling jQuery events

I have defined a class in JavaScript with a single method: function MyClass(text) { this.text = text; } MyClass.prototype.showText = function() { alert(this.text); } Then, I defined a method that acts as a handler for a click event, using jQuery: function MyClass(text) { this.text = text; $(‘#myButton’).click(this.button_click); } MyClass.prototype.showText = function() { alert(this.text); }; MyClass.prototype.button_click […]