HighDots Forums  

i need help

jQuery jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.


Discuss i need help in the jQuery forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bryre papata
 
Posts: n/a

Default i need help - 11-07-2009 , 05:12 PM






i am making an ant game, and i have a problem:


var x,y;
for(x = 1; x <= 10; x = x + 1){
images[x] = {
};
for(y = 1; y <= 10; y = y + 1){
images[x][y] = {
};
$(body).append('<im'+'g id="hi">');
var newid=x+", "+y;
$("#hi").css('id', newid).css('top',(y*10).css('left', (x*10))
}
}

i am pretty sure that there is a problem with the jquery lines, but im not
absolutly sure.


The JavaScript revolution has started!!! DOWN WITH FLASH!!!
DOWN WITH FLASH!!!
DOWN WITH FLASH!!!
http://www.chromeexpirements.com

Reply With Quote
  #2  
Old   
Dhruva Sagar
 
Posts: n/a

Default Re: [jQuery] i need help - 11-07-2009 , 10:01 PM






There are a few things I can point out.

1.) You might want to try $('body') instead of $(body)
2.) 'id' is not a CSS attribute, if you wish to change it's value, it should
be done like this :
$("#hi").attr('id', newid);
3.) [Suggestion] css() accepts a hash :
$('#hi').css({
'top': (y*10),
'left': (x*10)
});

Thanks & Regards,
Dhruva Sagar.




On Sun, Nov 8, 2009 at 3:42 AM, bryre papata <mr.jsnerd (AT) googlemail (DOT) com>wrote:

Quote:
i am making an ant game, and i have a problem:


var x,y;
for(x = 1; x <= 10; x = x + 1){
images[x] = {
};
for(y = 1; y <= 10; y = y + 1){
images[x][y] = {
};
$(body).append('<im'+'g id="hi">');
var newid=x+", "+y;
$("#hi").css('id', newid).css('top',(y*10).css('left', (x*10))
}
}

i am pretty sure that there is a problem with the jquery lines, but im not
absolutly sure.


The JavaScript revolution has started!!! DOWN WITH FLASH!!!
DOWN WITH FLASH!!!
DOWN WITH FLASH!!!
http://www.chromeexpirements.com

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.