jquery (self) on mouseenter leave | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

jquery (self) on mouseenter leave

Is there a better way to do this? https://code.sololearn.com/Wx6fAZKPTIW9 Instead of $("p").toggleClass("d_blue"); something like reference the div itself tex.: $(this).toggleClass("d_blue"); and leave the empty <p></p> tag in d_blue div Thanks

11th Jul 2017, 10:40 PM
Jozsef Sin
Jozsef Sin - avatar
2 Antworten
+ 10
Sorry i did not understand your question, do you mean something like this: $("div").on("mouseleave touchend", function(){ $(this).toggleClass("d_blue"); }); ... ?
11th Jul 2017, 11:39 PM
Maz
Maz - avatar
0
Ok i figured it out. https://code.sololearn.com/WK2BJs496A6V Changed this: $("p").toggleClass("d_blue"); to this: $(this).toggleClass("d_blue"); in function and removed the <p></p> tag in the html That was part of the next lesson
13th Jul 2017, 6:27 AM
Jozsef Sin
Jozsef Sin - avatar