You're fantastic! Thank you so much it works just perfectly! Greetz: BroOf
On 25 Dez., 21:10, "Michael Geary" <m...@mg.to> wrote: > My take on it would be similar to Kristaps', with a couple of differences: > > var string = '1/17/52;2/283/-2;3/475/492;4/180/625;5/272/790;' > var groups = string.split(';'); > for( var i = -1, group; group = groups[++i]; ) { > var values = group.split('/'); > $( '#' + values[0] ).css({ top:+values[1], left:+values[2] }); > } > > Also note that it's invalid for an ID attribute to begin with a digit: > > http://www.w3.org/TR/html401/types.html#h-6.2 > > I think a numeric ID may work in a jQuery selector anyway, but I haven't > tested it. > > -Mike > > > From: BroOf > > > Hey all! I build a function that creates a string with some > > informations. This is the structure: > > > 1/17/52;2/283/-2;3/475/492;4/180/625;5/272/790; > > > looks a little bit confusion but it's really simple. The > > first letter/ number (1) is the ID of an Div. the second > > number (17) is it's Y coordinate and the third number (52) is > > it's X coordinate. Then it continues with the second div (ID > > 2) and so on. > > My question now is: How do I split the informations into > > readable pieces? After splitting it should be placed with the > > .css function: > > > $('#1').css( "left", 52 ); > > $('#1').css( "top", 17); > > > ... > > > $('#5').css( "left", 790); > > $('#5').css( "top", 272);