erorr cardId is not defined | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

erorr cardId is not defined

why cardId is defined what is wrong with my script help me to solve this erorr https://code.sololearn.com/WwPdIuRf9qB5/?ref=app

14th Jun 2018, 8:58 PM
Hafizd Jubaidir
Hafizd Jubaidir - avatar
4 Answers
+ 1
when you set the wrapping to "onLoad" the functions you define are only defined inside that block, and cannot be accessed by outside event handlers. to fix this, change: function cardHide() {......} to window.cardHide = function() {....}
14th Jun 2018, 9:34 PM
MO ELomari
+ 1
ok thanks i just found out about this thanks Mohamed ELomari
14th Jun 2018, 9:38 PM
Hafizd Jubaidir
Hafizd Jubaidir - avatar
0
remove the parentheses from cardHide inside the addEventListener method
14th Jun 2018, 9:07 PM
MO ELomari
0
Mohamed ELomari ok thanks for success oh yes i want to ask again if i give event click in attribute so onclick = cardHide () why always erorr and the function named cardHide is defined why it can happen like this https://code.sololearn.com/WwPdIuRf9qB5/?ref=app
14th Jun 2018, 9:17 PM
Hafizd Jubaidir
Hafizd Jubaidir - avatar