Build a Popup With JavaScript
ฝัง
- เผยแพร่เมื่อ 19 เม.ย. 2019
- If you have used the web anytime in the last 5 years then you have most definitely run into an abundance of popups, also known as modals, which are quickly becoming one of the most popular components in web development.
In this video I will cover how to create a simple modal that animates in on button click, and fades out when the modal is closed. This modal is also able to be closed by clicking anywhere outside the modal which is something most tutorial don't cover. Lastly, this modal is setup in a way that it is incredibly easy for you to customize it to the needs of your exact website.
📚 Materials:
Code: github.com/WebDevSimplified/V...
🧠 Concepts Covered:
- How to use transform translate to center elements
- How to show/hide elements with a button click
- Smooth open/close animation transitions
- How to style an ugly modal 😜
- CSS position fixed
- Using CSS pointer events to prevent click events
🌎 Find Me Here:
Twitter: / devsimplified
GitHub: github.com/WebDevSimplified
CodePen: codepen.io/WebDevSimplified
#JavaScript #WebDevelopment #Modal
Hi, your way of explaining the each and every details and your approach of covering every dependent elements which are being used or going to be affected in the background is simply awesome.
Thanks a lot for covering it in a speedy but with a very simplified way.
This is most comprehensive and straightforward tutorial on modals I've ever seen. What makes it unique - handling multiple modals. Most of TH-cam educators show only how singular modal works.
Perfect timing! Was looking for a modal solution to a login form and this is just perfect. Thanks mate! :)
Glad I could help.
Hey bro, I just wanna say that Your vids have really helped me understand some concepts that I had a hard time grasping in my bootcamp. keep up the great vids!
Seriously strong video... concise, well paced, extremely well organized and well presented . Great job!
Nothing to add to that!
Dude, you rule. I have been pulling my hair out trying to deal with other modal methods. Thank you!
This content is golden! Not only is it short and direct to the point, but it also shows off a lot of very useful techniques! It is very seldom that I come across videos like this! Thanx for being awesome and sharing this!
Kyle, your videos are a true lifesaver. I'm a pretty good coder - for a hobbyist at least, but my CSS knowledge is pretty basic. Because of this, I used to have some complex functions to handle button clicks on elements that have children, since the target of the event can be either the clickable element, or one of its children. If only I knew about pointer-events sooner, that could have saved me so much time!
There's a lot of great JS and CSS content out there, but in the last couple of years, I've always come back to your videos. Thanks for all the effort!
Honestly, you're my favorite dev youtuber !
Each details are explained extremely well and without search your word !
Excellent! And far more sophisticated than I would have done myself... really appreciated.
Absolute Fire in 15 minutes. Your videos are incredible, and super easy to follow. Thank you.
Thank you for the tutorial! I just subscribed so I'll definitely be watching more of your tutorials.
im not joking when i say you have taught me more about web development than any college programming course did. Thank you for teaching the public in a very clear concise way.
Thanks a lot, man, your videos are always helpful. Keep up the good work.
That was an awesome tut as always! - lol needed a refresher on this topic, thank you !
Thanks, kyle. I don't know how I will appreciate your efforts. you made me understand how I will put my javascript skills into real-world projects
Another great job (as usual). Thanks.
Thank you! I was looking for something like this and you helped me really much with my popup for my chrome/firefox extension. Without you, I would have skipped it completely and only used boring html headers inbedded in the site which would've looked awful and barely worked.
Thank you so much! You helped a lot and explained perfectly!
Man you rock! Thanks again for this one. Keep up the great work!
Thank you!
You have the best videos! So grateful
Thank you so much, man. Great, informative tutorial.
Wow! your way of teaching is amazing! it's straightforward, explains everything directly in short words, is well presented, prepared, and very very clean and organized. Thanks, many many thanks.
Love this! Thank you for this. ;) Learned a bunch.
Thank you. I'm glad you enjoyed it.
This is so perfect and well explained. All the modal popups that I have check, they make it over complicated.
A great behaving modal and great technique as well. Great job. Thank you.
Great video. This helped me a ton! This channel is awesome!
I've just gone mental trying to do this using stack, gpt and other videos. Gonna have some trouble with databases trying to get the modal to reflect the information relevant to which image was clicked but hopefully a bit of python can sort it out. You're such a good creator, 10 stars
exactly what i was looking for!
You are the best, awesome explanation, step by step , ty
the official Kyle pop up. I got so much from this video thanks. I love the way you popped up in the beginning. lol
Just what I need, perfect!
Yes! This is precisely what I need for my software, thanks
You are justifying the name of this channel. thanks 🙏
High quality content. Well done and thank you!
Thabk you. I'm glad you enjoyed it.
Thanks kyle you really helped me on my project looking for a carousel tutorial in the future.
Thank you for sharing this code. i have been searching modal pop code for a long time, finally i found what i wanted
I'm glad I could help!
i really love your contents! thanks!
Thank you bro 👊....
I was wondering the way I will create my own modal without
Bootstrap.
But now you turned me to it .
Great tutorial! Easy to follow.
I tried it by myself at first but yours looks so much better. Also never heard of data-* until this video
This is Fantastic, Thank You.👍
thank you for this tutorial it really helps
Very interesting! I'll definitely incorporate that into some of my projects!
Thank you so much,so much i learned from this video.. Thank you again! Hope one day ill make this easy like you... Thanks !!!!
Great video bro, thank you!
you are a lifesaver, thank you so much!!
Great tutorial!
Awesome! Thank you
Very good tutorial learned alot thanks!
Excellent Tut. Enjoyed it very much
It is really helped me. Great work
Thank u my friend! Very Strong tutorial
Came here for the modal turotial, left with a lorem shortcut. Gotta love it!
Great job - thanks 👍
Thanks, this is very helpful and simple to understand. A lot of the code can be avoided if you are triggering the popup on some event and not a button (in my case when you lose in the game).
lovely video, helped me a lot
7.8 billion people should be subscribed to you
love your explanation man..
Holy moley. That is a lot of work to create a modal.
Excellent code sample and explanation! Thanks for putting this video together. I will subscribe to your channel.
OMG... you save my life bro, tnx!
great tuto. thank you
bes tutorial ive ever seen and you show the code when youve done . ill give you a cheeky sub
Awesome. Thank you
that is what I was looking for
mAAAAn, thx I'm making the project and had some troubles and ur video solved it, big thx u)))
Thanks so much!
Bro pointer-event :none does make everything insensitive to touch or click event but when you use this property it is able to click a button and if we use z-index instead of event-pointer then still button is non clickable .why?
Ótimo vídeo era oque eu estava precisando obrigado.
Great video! It's what I needed, thanks - just a quick translation if he needed it.
bro u deserver million more subscribers!
You can build bootstrap v6.0 alone.. popup, accordions, this and that.. and you have no idea how much knowledge you have man! 😄
Thanks so much for this! Very clear :)
Any suggestions on how to have the content inside the modal be pulled from somewhere besides the HTML upon a click event? Like a dynamically loaded footnote (or something like that).
Wow! I looked for something like this all afternoon. I have some modals that i need to close programatically ! All i found was jquery options. I wanted to use vanilla js. Thank u! Well explained, to the point.. great ⭐⭐⭐⭐⭐
Thanks, you are the best
tHANKS TO SHARE THIS VIDEO WAS AWESOME..!
AND VERY USEFULL..! PLEASE DO IT MORE...! SUCCEEDS..!
thank you very much!
Perfect!
this is awesome, exactly what I was looking for. I do have a question though, if I have a button inside the modal that triggers another modal (so the white section replaces each other - Bootstrap uses the data-dismiss data-toggle) but the overly stays. how do I go about this?
If we create two modal buttons the functions does respond to eachone so that's the purpose of selector forEach?
thank you so much!!!
Pretty good. It just drives me crazy that you didn't use a single semicolon in JS.
I don’t use semicolons😊
I use but it is not mandatory....i dont know y 🤣🤣🤣
Очень классно и понятно!!!спасибо. Cool!!! thank you
Great Describing !
Thanks mate. Your tutorials are precious. If you can do a video on throttling and debounce it will be very helpful.
I'm really glad my videos help. Debounce is a fairly technical and advanced topic, which I generally believe is done better through text. That said, I will look into seeing if I can figure out a good way to teach that concept through video.
@@WebDevSimplified Thanks for the reply.
Thank you so so so much
Thank you so much sir
good one!
Thanks bro you're a badass :)
Really Good
Hi, just wondering do you have to have the modal on the same page as the button? What if you want a navigation bar across different pages and one reusable login/register form modal and not copy and paste the modal on every page...how would you get around that?
The modal dialogs are complex matter on various levels (template abstraction, vertical scrolling, responsiveness, focus, tabindex, etc), but this tutorial is a good starting point. Never ever though remove css outlines from focusable elements - for the sake of accessibility.
Thanks a lot
Thank you for the great video. can you make a video explaining how to get those pop-up triggers such as time and intent to exit
THANK YOU
Pretty straightforward and beginner friendly. Great job!
Only issue I'm having is that the modal is triggered on page load instead of on button click. Pls what should I do
alhamdulillah, thank u very much!
Any clue how to loop through all the other button and close the active ones before opening a new one?
Awesome explanations! Quick question. What is the 'live server' you were referring to? How can I use it?
Thank you