javascript recursive parse object

    displayMsg(data.message);  
    var displayMsg = function(msg){
        if(typeof(msg) == 'object'){
            var rs = recursiveParse(msg);
            alert(rs);
        }else if( typeof(msg) == 'string'){
            alert(msg);
        }
    }
    
    var recursiveParse = function(obj){
        var arr = new Array();
        $.each(obj,function(i,v){
            if(typeof(v) == "object"){
                arr.push(recursiveParse(v));
            }else{
                arr.push(v);
            }
        });
        return arr;
    }    
Advertisements

SVG example

<!doctype HTML>

<html>

<body>
<div id=”svg-wrapper” style=”margin-top:500px;”>
<svg xmlns=”http://www.w3.org/2000/svg&#8221;
xmlns:xlink=”http://www.w3.org/1999/xlink”&gt;
<style type=”text/css” >
<![CDATA[
polygon {stroke:#660000; fill:#cc3333; cursor:pointer;}
polygon.green {stroke:#660000; fill:#00ff00;}
polygon.blue {stroke:#660000; fill:#0000ff;}
polygon:hover {opacity:0.7;}

]]>
</style>

<polygon id=”lot1″ rel=”” class=”green” points=”0,0 50,0 25,50″/>
<polygon id=”lot2″ class=”blue” points=”100,0 150,0 125,50″ />
<polygon id=”lot3″ points=”200,0 250,0 225,50″ />

</svg>
</div>

<div id=”test” class=”descrip”>
desc
</div>

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js”></script&gt;
<script>
$(“polygon”).bind(‘click’,function(){
$(this).remove();
});

 

</script>

</body>

</html>