O'Reilly Forums: Trouble Ch3 - O'Reilly Forums

Jump to content

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

Trouble Ch3 MISS OF INFORMATIONS,

#1 User is offline   aerosky 

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

Posted 15 January 2013 - 01:38 AM

Hello everybody i have just bought this book and i was really happy with it (sorry about my english i'm French) but there i a lack of information in the chapter3.
In the exercice where we are asked to write a function to hide the discount,

the solution is getRandom(4) so we were told that the random method was betwwen
0 to 1 it means that this function will return one of these numbers 0;1;2;3;4. This random number is compare with the index variable (there is no explication about these two arguments (index,value ?? are they automatic arguments when we use the each method??. If the index argument mean the index of the tab return by each (we have been told that the fisrt number was 0). So the first function should take any random number beetween 0;1;2;3 i mean getRandom(3) not (4). I don't know if i'm right .

Last question: in the chekCode function the contain method compare (this, and documentGetElementByID("has_discount") but what mean the "$" from

if($.contains Does it mean $(this)?

Thnkas by adavnce

aerosky
my code is wrong and i copy exactly the same things as the book can somebody check Thanks again for your time

nb: the second file has been renamed html instead of js if not i could not load it

Attached File(s)


0

#2 User is offline   __Adnan 

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

Posted 27 January 2013 - 08:22 PM

$(this).append("<span id="has_discount"></span>") //on ajoute l'id has_discount


The above line is from your file, change it the line bellow and see if it works.

$(this).append("<span id='has_discount'></span>"); //on ajoute l'id has_discount


you need single quotes around "has_discount" and you also forgot ";" at the end.
0

#3 User is offline   aerosky 

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

Posted 27 January 2013 - 10:51 PM

View Post__Adnan, on 27 January 2013 - 08:22 PM, said:

$(this).append("<span id="has_discount"></span>") //on ajoute l'id has_discount


The above line is from your file, change it the line bellow and see if it works.

$(this).append("<span id='has_discount'></span>"); //on ajoute l'id has_discount


you need single quotes around "has_discount" and you also forgot ";" at the end.



Thank you.
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