0

Help me to add this..

Image should get fullscreen when clicked and back to normal when click again. I want to add this. How can i? https://code.sololearn.com/WuA39xPK4STr/?ref=app

2nd Aug 2021, 4:03 PM
Salman B
Salman B - avatar
7 odpowiedzi
+ 1
I saw your code... And I found a better way to do that. You only need one element that have an ID and two classes, the first class have the small format and the second class have the expand formad, so you just need to toggle the second class because this overwrite the first class, in js search you element by the ID and toggle the second class, just the second class. Like this: <div class="firstClass" id="element"></div> .firstClass{ width:50%; } .secondClass{ width:100%; } $("#element").click(function(){ this.toggleClass("secondClass"); });
2nd Aug 2021, 6:23 PM
Luis E. Gómez Mena
Luis E. Gómez Mena - avatar
+ 1
Because you need to add the code for each element, changing the id $("#id").click(function(){ this.toggleClass("secondClass"); }); Or add the name atribute in each one and change the script <div class="firstClass" name="element"></div> $('td[name="element"]').click(function(){ this.toggleClass("secondClass"); });
2nd Aug 2021, 6:40 PM
Luis E. Gómez Mena
Luis E. Gómez Mena - avatar
+ 1
I am not using id. I changed id into class. You can check my code.
2nd Aug 2021, 6:49 PM
Salman B
Salman B - avatar
+ 1
Great, you understand how it works
2nd Aug 2021, 6:54 PM
Luis E. Gómez Mena
Luis E. Gómez Mena - avatar
0
Thank you so much. It worked. But next image is not working why?
2nd Aug 2021, 6:32 PM
Salman B
Salman B - avatar
0
Yes i got it. Thank you bro.
2nd Aug 2021, 6:35 PM
Salman B
Salman B - avatar
0
Yes thank you so much
3rd Aug 2021, 7:50 AM
Salman B
Salman B - avatar