Jump to content


Photo

Trouble Ch3


  • Please log in to reply
2 replies to this topic

#1 aerosky

aerosky

    New Member

  • Members
  • Pip
  • 7 posts

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 Files



#2 __Adnan

__Adnan

    New Member

  • Members
  • Pip
  • 5 posts

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.

#3 aerosky

aerosky

    New Member

  • Members
  • Pip
  • 7 posts

Posted 27 January 2013 - 10:51 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.



Thank you.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users