Posts in 'JavaScript & Ajax'
JavaScript: Send function as a parameter to another function (callbacks)
Posted on 29. Jul, 2009 by Dragos.
I’m sure you’ve seen a lot of code where functions are send as parameters, usually working as function callbacks e.g: setTimeout(function () { alert('test'); },1000); But how does the function setTimeout execute the passed function as a parameter? The answer is simple, but I need to provide you an example to understand it Let’s create [...]
Continue Reading
JavaScript: GIFless animation. Animate images,logos with jQuery
Posted on 23. Jul, 2009 by Dragos.
After playing some time with position relative and absolute, I’ve noticed one a great aspect of the png image format (probably gif images are also good, but since we are trying to create a GIFless animation, I won’t use any gif images in this tutorial). So here’s a a PNG (transparent text), with the name [...]
Continue Reading
JavaScript: How to get the index (position within a group) of an object with jQuery?
Posted on 20. Jun, 2009 by Dragos.
I’ve spent some time today figuring out how to obtain that index and finally I’ve just puzzled it out. Let’s say we have a group of objects all containing the class=”house”. Now if we are referencing to the first element within the group and we’d like to find out it’s index (well it’s obvious in [...]
Continue Reading
JavaScript: What if jQuery animation doesn’t fire/start?
Posted on 19. Jun, 2009 by Dragos.
I’ve been working on an image gallery (that I will publish here for all to see and use) and I ran into an issue that I’ve never experienced before: jQuery stopped firing the animation of an object. I looked at the expression, everything was fine. However not the expression was the problem, but the variables [...]
Continue Reading
Javascript: How to validate email address with JavaScript?
Posted on 13. Jun, 2009 by Dragos.
Here’s a piece of code I found while I was browsing the JQuery UI pages to easily validate email addresses. The code below represents a general validation function, that requires two parameters:1. the string value of an obkect and 2. the regular expression to check the string against function checkRegexp(o,regexp) { if ( !( regexp.test( [...]
Continue Reading
JavaScript: Get anchor from URL
Posted on 10. Jun, 2009 by Dragos.
To get the anchor from an URL (this is the text after the # character) in JavaScript you can use the following code: var url='http://iwebdevel.com/some-post#comment-1'; //if you need to take the current url of the window use: var url=window.location; var anchor=url.hash; //anchor with the # character var anchor2=url.hash.substring(1); //anchor without the # character If you’re [...]
Continue Reading
JavaScript: Where do I Find All Properties for All HTML Elements ?
Posted on 08. Jun, 2009 by Dragos.
You think you’re good at JavaScript? Ok. Here’s a question that’ll test your JavaScript wisdom: How many properties does a DIV element have? Your answer is 5? Because there is the name, id, class, style or title property. Maybe your answer is a little bit more than 5, but would you be surprised if I [...]


