Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7617559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:10:51+00:00 2026-05-31T03:10:51+00:00

I am using the following code to change the id of a div to

  • 0

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?

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

function grav_treasure(){
var i=0;
for(i=0;i<=treasure_list.length;i++){
    var id = treasure_list[i];
    if($("#"+id).length > 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 > 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 > 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 > 0){
                alert(new_id);
                $("#"+id).attr('id',new_id);
                grav_treasure_tree(id, row);
            }
        }

    }
}
setTimeout("grav_treasure()",100)
}

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T03:10:52+00:00Added an answer on May 31, 2026 at 3:10 am
    $(document).ready(function(){
        var id = "original";
        var row = "some_row";
        var col = "some_col"
        var treasure_list = [];
        var grav_treasure_tree = function(id, row){
            // some code
        }
    
        var rand_id=Math.floor(Math.random()*100);
        var new_id = "treasure_grass_"+row+"_"+rand_id;
        new_id = new_id + "_col_" + col;
        treasure_list.push(new_id);
        if($("#"+id).length > 0){
            alert(new_id);
            $("#"+id).attr("id",new_id);
            grav_treasure_tree(id, row);
        }
    });
    

    That works if I have a div with id original:

    <div id="original">
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code. The code works, but I want to change it
I am currently using the following code to update form data before submission. $('.countyx').change(function(){
I am using the following code, UIManager.put(JFrame.activeTitleBackground, Color.red); for change the toolbar color in
How to change the width/height if I have the following code and using php:
I'm using the following code. By clicking on div id=popUpPane , the div and
I am using the following code to change font text of whatever typed in
All, I'm using the following code: $(document).on('change','.found_other_vendor',function(){ if(checked){ alert(it was checked); if($(#other_liked_vendors).val()!=){ alert(second_one); $.post(ajaxurl,
I want to change the width of elements rendered using following code. I have
I am using the Following Code. It works fine but the problem is that
I have been working with the slider and am using the following code: $(function(){

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.