September 3rd, 2010


How to align vertically an element with JavaScript

by Dragos, on December 24th, 2008  

If you would like to align an element vertically within a parent element, i use the following script.

<script type=”text/javascript”>

if (typeof window.innerWidth != ‘undefined’)
{
bh = window.innerHeight
}
if (typeof document.getElementById(“myElementID”).offsetHeight != ‘undefined’)
{
mbh = document.getElementById(“myElementID”).offsetHeight
}

document.getElementById(“myElementID”).style.marginTop=Math.round((bh-mbh)/2)+’px’);

</script>

This will arrange an element in the middle of a webpage.

Create a simple content rotation script with fading effect using JQuery

by Dragos, on November 24th, 2008  

I came up with a simple solution to rotate some divs, having a cute fade in effect. For that i used JQuery.
Supposing you have a div container, you put in it smaller divs which you will use for rotation.

Content in div number one.
Content in div number two.
Content in div number three.

Notice that each div to [...]

Jquery slide effect

by Dragos, on November 18th, 2008  

I needed to know what happens when Jquery applies the slide effect animation to an element. I read in their documentation they told it changes the height (didn’t specify which one). I tried to read it with $(“#el”).css(“height”) , but it was not the one i needed. Then i tried $(“#el”).attr(“offsetHeight”) which is what i [...]

How to Fade Background Colors with Jquery

by Dragos, on November 1st, 2008  

I just needed to make a fading effect with background colors, but it didn’t work for me even if i did everything correct. I missed one important step that took me some precious time. I forgot to include the optional effects package, which contains the transitions between colors and classes.
Just included:

in the head of my [...]

How to apply change to all TDs within a TR (columns withing a row)

by Dragos, on October 5th, 2008  

I wanted to change the background color for a row with document.getElementById(row_id).style.backgroundColor=’red’ but unfortunately that doesnt work for some reason. Then i thought this could be done by applying the same style to all of the columns within a row (all TDs withing a TR). I’ve searched the web for such a function but i [...]