Monday, November 10, 2014

Dynamic-CSS Example 4 - Multi-occurrence of variable


warning : this post is based on previous posts. be sure you read them.

In this post we will create one variable and use it multiple times.


Code
-----------------------------------------------------------
$('#container').children().filter('div').dcss(
    {   
    width : '<len>px',
    height : '<len>px' 
    },
    { 
        len : function(i,el,c){return 30 + Math.random() * 100;}
    });
    
}; 
-----------------------------------------------------------

Here "len" variable defined one time and applied to 'width' and 'height' property. so we expect drawing randomly  sized squares on screen.

Running





No comments:

Post a Comment