jQuery has a great helper function called hover which takes two functions as it’s values.
$('#hover_div').hover(function()
{
/* something to do on mouseenter */
},
function()
{
/* something to do on mouseleave */
});
Great when you want a simple way of doing something when your mouse enters or leaves the selected element(s).
Continue Reading… »
Posted by Harry at 6:52 pm on November 24th, 2008.
Categories: Javascript, jQuery.
Put your hands up if you hate developing for Internet explorer….
That would be most of you then.
I can’t stand its special ways of doing things, so when I find an easy work around it makes me happy.
The latest one I have had to find and put into practice is a method for disabling some Select dropdown options in a form. Internet explorer doesn’t support the disabled attribute on option elements. The following code will only work in standards complaint browsers (not in IE 6 or 7):
Continue Reading… »
Posted by Harry at 3:15 pm on November 19th, 2008.
Categories: Javascript, jQuery.
A little bit of a strange one I know.
But recently I needed to be able to get the total of all items that another ebay user had for sale. By default they can see it but another user cannot.
So using the console of firebug in firefox paste the following javascript and off you go.
Continue Reading… »
Posted by Harry at 2:12 pm on November 17th, 2008.
Categories: Javascript.
Every tried to comment out a large part of a script only to find that your /* multiline comments */ don’t work because somewhere in that file you already used /* multiline */ type comments?
Well never fear. A solution for php, Javascript and plenty of other languages is simply to use
if(0)
{
... lots of code ...
}
Simple and quick
Posted by Harry at 4:29 pm on November 13th, 2008.
Categories: Javascript, PHP.
If you have a string in javascript and you want to the first letter to be uppercase / a capital then this line of code will do that for you:
str = str.slice(0,1).toUpperCase() + str.slice(1);
If you want to convert more than one letter then you might want to use the following. As examples if you wanted the first 4 characters uppercase use (0,3) and then (4) and if you wanted the first 2 uppercase you would use (0,1) and then (2)
str = str.slice(0,3).toUpperCase + str.slice(4);
Remember that an array starts at zero so always take one from the numbers you want.
Posted by Harry at 10:12 pm on November 9th, 2008.
Categories: Javascript.