O'Reilly Forums: Chap 6 Magnet - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Chap 6 Magnet var $d=$("div")

#1 User is offline   aerosky 

  • New Member
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 15-January 13

Posted 27 January 2013 - 11:02 PM

Hello and thanks by advance.
I m French so sorry for my poor english :)

I don't understand what happenened with the code below and nothing is explained about what is doing this part of code.
var $d = $("div"); line20 //$d get now a table of all the divs
$d.addClass("current_hand) // it means that all the div will get the current_hand class ?
.appendTo ("#my_hand"); //the div my_hand will receive all the div with the class current_hand ?? i don't understand what happened

$("<img>").appendTo($d) ??

Sometime many things are really well explained and explained with many ways. And sometimes a huge part of code is written without mzny explication.

I 'll be very happy if you could explain me what is doing actually this part of code page 234

Thanks again
0

#2 User is offline   __Adnan 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 16-September 12

Posted 28 January 2013 - 06:56 PM

var $d = $("div");  line20   // here we are creating a new div element and storing it into $d 
$d.addClass("current_hand")   // here we are adding class "current_hand" to the element we stored into $d
.appendTo ("#my_hand");  // here we are appending the element $d to a element which has the id #my_hand

$("<img>").appendTo($d) 


0

#3 User is offline   aerosky 

  • New Member
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 15-January 13

Posted 29 January 2013 - 12:22 AM

Hello and thanks helping me each time

var $d = $("<div>");
i don't understand why this command is creating a div instead of select the div. the syntax $("jjjjj") is to select not for create

so $("<img>") mean that we are creating a new image ? In this case i understand better

to conclude how i know if i'm selecting or cretaing $("p") is selecting $("<div>") is creating because of the < and > sign


Thanks again
0

#4 User is offline   __Adnan 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 16-September 12

Posted 29 January 2013 - 02:01 AM

yes, you are right; it is creating because of < and >
0

#5 User is offline   aerosky 

  • New Member
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 15-January 13

Posted 29 January 2013 - 03:32 AM

View Post__Adnan, on 29 January 2013 - 02:01 AM, said:

yes, you are right; it is creating because of < and >



thanks again
0

#6 User is offline   aerosky 

  • New Member
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 15-January 13

Posted 29 January 2013 - 08:18 AM

Hello

i try what we have told

$("<p>").html("sssss");

i had this script in the my_scripts.js in order to test if à new <p> had been created with sssss inside.
when i run the index.html file there is no my new p :(

I put it just under tne .ready function()
burt nothing happened


thanks aerosky
0

#7 User is offline   __Adnan 

  • New Member
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 16-September 12

Posted 31 January 2013 - 07:06 AM

var $B = $("body");
$("<img>").appendTo($B);


you need to append it to some other element like you did before in the above code.

This post has been edited by __Adnan: 31 January 2013 - 07:12 AM

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users