Jquery change id, not working [SOLVED]
<p>I am using the following code to change the id of a div to something else, but it's not working??? Does anyone know why?</p>

<p>the if statement gives back a true so the div with the id of 'id' does exist but it's not running the actual line that changes the id</p>

<pre><code>function grav_treasure(){
var i=0;
for(i=0;i&lt;=treasure_list.length;i++){
    var id = treasure_list[i];
    if($("#"+id).length &gt; 0){
        var current_top = document.getElementById(id).style.top;
        var current_top = parseFloat(current_top);
        var id_split = id.split("_");
        var row = id_split[2];
        var row = parseFloat(row) + 1;
        var col = id_split[5];
        var col = parseFloat(col);
        var block_id = "row_" + row + "_col_" + col + "_type_grass";

        if($("#"+block_id).length &gt; 0){
            if(document.getElementById(block_id).getAttribute('class')=="block"){

            }
            else{
                var rand_id=Math.floor(Math.random()*100);
                var new_id = "treasure_grass_"+row+"_"+rand_id;
                var new_id = new_id + "_col_" + col;
                treasure_list.push(new_id);
                if($("#"+id).length &gt; 0){
                    alert(new_id);
                    $("#"+id).attr('id',new_id);
                    grav_treasure_tree(id, row);
                }
            }
        }
        else{
            var rand_id=Math.floor(Math.random()*100);
            var new_id = "treasure_grass_"+row+"_"+rand_id;
            var new_id = new_id + "_col_" + col;
            treasure_list.push(new_id);
            if($("#"+id).length &gt; 0){
                alert(new_id);
                $("#"+id).attr('id',new_id);
                grav_treasure_tree(id, row);
            }
        }

    }
}
setTimeout("grav_treasure()",100)
}
</code></pre>

<p><strong>Sorry for anyone who tried to answer this, I made a small mistake by inputing a wrong variable into a function which screwed up everything, so there was actualy nothing wrong with the script above. Sorry :( but thanks for all your help!</strong></p>
