0

if(buttonA is pressed != button b is pressed) doo....?

Hi how the titel may tell you i want sth that can do: if(buttonA is pressed != button b is pressed) doo....? till know i have this: https://code.sololearn.com/WS8L15d5G63b but idont know why my pressed function is not working if(sP!=mP){ for(x=0;x<moduls.length; x++){ el.removeChild(el.lastChild)} click =0; } else{} cause if i click on "1 Semester" the sP should be 1 and the mP 0 hope someone can help me

31st Oct 2018, 10:00 PM
jack
jack - avatar
16 odpowiedzi
+ 1
See here, read ALL comments and ask if you needed https://code.sololearn.com/WdLNtzaRJ87h/#js P.S. This is not the best way to do, but its useful forr your undestanding
1st Nov 2018, 1:38 PM
KrOW
KrOW - avatar
+ 2
Thank you 😊
1st Nov 2018, 3:09 PM
KrOW
KrOW - avatar
+ 2
jack Its used for indicate if #demo have children inserted in it (see the condition in a function). I writed than its possible do without it also because, inside a function, you can test if #demo have children with if( el.children.length > 0) Where el is #demo and if it have childs, it mean that current click must REMOVE all while if it have not child it meant ADD all childs Anyway, i come from Italy
1st Nov 2018, 7:24 PM
KrOW
KrOW - avatar
+ 1
jack i didnt understood the problem.... Can you explain better?
31st Oct 2018, 10:23 PM
KrOW
KrOW - avatar
+ 1
jack Then reviewing: On clicking #demo you add modul items inside it almost like a list. After this, of you click on an item what must happen? In your code seem that you want load an iframe (remember iframe and not ifram 😉) by changing on click the src (here also, src and not scr 😉😉) attribute...Then, you want that on clicking #demo (after it have moduls) all moduls would be removed while on modul click, iframe loading would happen? P.S. Why you used mouseup and mousedown listeners? What they would do?
1st Nov 2018, 9:10 AM
KrOW
KrOW - avatar
+ 1
THANKS A LOT! !! so much help realy good explained I'll read later the hole document when I have more time. Thanks for helping me sooo well
1st Nov 2018, 2:04 PM
jack
jack - avatar
+ 1
didn't get why it is out of security reasons saver to hide the ofram
1st Nov 2018, 2:59 PM
jack
jack - avatar
+ 1
great attitude man
1st Nov 2018, 3:05 PM
jack
jack - avatar
+ 1
hey Krow I didnt get what you ment with this last sentence: This var will be used for detect if moduls are added to #demo (you can dont use it also but i added it just for your understanding) */ and by the way where you from ;-)
1st Nov 2018, 7:02 PM
jack
jack - avatar
0
sure I want in this example : when I click on semester it will open the Moduls and now I want If I click on modul that just the click event of modul get triggert and not from the div of semester
31st Oct 2018, 11:39 PM
jack
jack - avatar
0
there is the div id=demo with the paragraph "1.semester" if you click on it the div will get children with the paragraph "modul 1" "Modul 2" ... now I want that if I click on the div "1 Semester" that the children get removed but not if I click on modul. because the modul is inside the dive "1 Semester" it removes the modules than I click on modul
1st Nov 2018, 6:55 AM
jack
jack - avatar
0
hope that helped you
1st Nov 2018, 6:55 AM
jack
jack - avatar
0
yes you got it:) I used mouse up and down to know when it's been clicked just on #demo and when also on modul and too add functions in the moment the click ends
1st Nov 2018, 10:19 AM
jack
jack - avatar
0
I want If I click #demo the Moduls open and click #modul the iframe opens
1st Nov 2018, 10:26 AM
jack
jack - avatar
0
jack Dont worry.. My main goal here is help other users (and learn with they) 😉😉😉 P.S. If you dont understand something, ask 👍👍
1st Nov 2018, 2:06 PM
KrOW
KrOW - avatar
0
Because hiding it make iframe dont break events handling (it cannot receive events when hided) and allow to make all works
1st Nov 2018, 3:04 PM
KrOW
KrOW - avatar