Build a Slider with One Line Of Javascript Code

Поделиться
HTML-код
  • Опубликовано: 13 янв 2025

Комментарии • 183

  • @lundeveloper
    @lundeveloper  2 месяца назад +17

    Next video will continue to be about three JS, it will be a truly impressive video 😁😁

  • @maksymdemchenko
    @maksymdemchenko 2 месяца назад +25

    Gosh, a slider without sliding, incredible!

  • @lundeveloper
    @lundeveloper  2 месяца назад +16

    Don't forget to like and subscribe to watch many interesting videos about programming and web design 😍

    • @Samarsinghvxs
      @Samarsinghvxs 2 месяца назад

      hey bro i am high school student if i learn mern that can add value to me and i can earn from it

  • @MdMamun-xl6iq
    @MdMamun-xl6iq 2 месяца назад +12

    Sliders were my nightmare, really. But because of this video it is so simple and easy for me now, i thank you very much...keep making simplified videos like this one ❤❤❤

  • @BeastGuru52
    @BeastGuru52 2 месяца назад +8

    best web creator i have seen in my life keep it bro

  • @MrSharksk
    @MrSharksk 2 дня назад

    god, thank you man, it was so easy to do, chatgpt gave me solution based on width 100% etc, it wasnt good for me, as i wanted to change whole DIV which is not 100% width, but your solution makes it perfect !

  • @toxyninja8635
    @toxyninja8635 20 дней назад

    Este es el vídeo que definitivamente estaba buscando, me encanto mucho, gracias por subir este tipo de contenido

  • @lundeveloper
    @lundeveloper  2 месяца назад +4

    Variable declaration and function declaration are obvious so we will not count, we will only count the logical lines of code.

    • @Samarsinghvxs
      @Samarsinghvxs 2 месяца назад

      as a js easy loops it helps so much u solve my problem

  • @hemantduttacodes
    @hemantduttacodes 2 месяца назад +14

    That's a carousel, not a slider. But still a very informative video. I like the way you're teaching people to learn to code in unique ways rather than following the norm. Keep it up!

  • @mr.kunjrami9026
    @mr.kunjrami9026 2 месяца назад +1

    I mean its unbelievable that you dont need to write a bunch of LOC to make the slider...Hats off👍🙌

  • @rifatmunna
    @rifatmunna 2 месяца назад +1

    yeah you can do it to with only display:block based on active index . and use index = (index + 1) % array.length

  • @SergeyNeskhodovskiy
    @SergeyNeskhodovskiy 2 месяца назад +1

    The catch is that you won't be able to apply any sort of animation or transition to this slider, because all animations and transition rely on properties and in this case, there is no property to be targeted, the element just appears in the DOM tree or disappears from the DOM tree. Thinking about it further, you could try something like @starting-style which doesn't yet have wide browser support.

  • @lundeveloper
    @lundeveloper  2 месяца назад +18

    Maybe if I were more concise, it would only take us 1 minute because it's really only one line of logic code 🤣

    • @Elongatedrider
      @Elongatedrider 2 месяца назад

      Great video as always❤,how did you develop this creative way of thinking for coding man?

    • @alamanshaikh5009
      @alamanshaikh5009 2 месяца назад

      long explanation better

  • @migliorelli
    @migliorelli 2 месяца назад

    what do you think about sliders with a scrolling div and an tag?

    • @FACKDAWURLD
      @FACKDAWURLD 2 месяца назад +1

      It would be same code, just replace the Img query selectors with a

    • @giovannielias8153
      @giovannielias8153 2 месяца назад

      Probably it would be something like this:
      ```HTML




      ```
      ```CSS
      /* get all anchor tags that are not the first item from childrens of slider*/
      .slider a:not(a:first-child){
      display: none;
      }
      ```
      ```JS
      let slider = document.querySelector('.slider')
      let nextBtn = document.getElementById('next')
      nextBtn.onclick = () => {
      slider.append(slider.querySelector('a:first-child'));
      }
      ```
      *But remember that, now the img is inside the anchor tag, and for future styles, probably you will need to change one or both elements*

    • @giovannielias8153
      @giovannielias8153 2 месяца назад

      Now that you are having a anchor tag, be careful with just setting display to none, because *that won't be accessible* .
      Take a look for *disable* and *aria-disable* and make you site even mor accessible ; P

  • @dhmmasson
    @dhmmasson 2 месяца назад +1

    Wow, an interesting side effect of the DOM being a tree, appending the element forces it to be removed from its original place, creating the moving effect. Very nice, what's mind-boggling is that from a javascript perspective, we expect the variable ul to be an array since you use append on it. But ul is an Element. The behavior should probably documented on MDN

  • @diobrandoggo7471
    @diobrandoggo7471 2 месяца назад

    Today I learned about the with id being appended and just moves. Showing the technical aspect is a masterclass. Btw, how does it fare with animation???

  • @altero7461
    @altero7461 2 месяца назад +3

    Ur briliant developer

  • @ipa_stor
    @ipa_stor 2 месяца назад

    As always, thanks for a new video - simple and creative. The idea of a couple answers in the end is great.
    Threejs video gonna be epic🔥

  • @bazz6932
    @bazz6932 2 месяца назад

    Already knew this but thanks for the refresher

  • @svampefett
    @svampefett 2 месяца назад

    Love the fireship graphics.

  • @khouchanemahmoud9475
    @khouchanemahmoud9475 2 месяца назад

    Wow, a slider in less than 5 minutes😅 .This is why i like this chanel always a simple trick can do the work.Keep up the good work

  • @Graphicstopprod.o
    @Graphicstopprod.o 2 месяца назад

    King web dev never seen these solutions ❤

  • @waleedbinshabbir1542
    @waleedbinshabbir1542 2 месяца назад

    I love your videos, they are so simple and break down the concepts amazingly.

  • @joel-rg8xm
    @joel-rg8xm 2 месяца назад

    Time to change my coding mindset ... and the JS documentation

  • @ATHARVALANDGE-u4e
    @ATHARVALANDGE-u4e 2 месяца назад

    Love your content, cant wait for the next awesome trick!!!!

  • @martinharyanto4465
    @martinharyanto4465 2 месяца назад

    Can you continue this slider with animation? I think animation is a very interesting topic to cover.
    It can get messy and big, but to understand the basic and its simplest form would be a killer !
    Very clear and good video btw !! 👏

  • @MustaPha-s4i
    @MustaPha-s4i 2 месяца назад

    Really you are from the best creator, i love your Channel and i was happy when i see notification

    • @lundeveloper
      @lundeveloper  2 месяца назад

      Thanks for watching my content brother 😍

  • @amaizingcode
    @amaizingcode 2 месяца назад

    Thank you for your videos and the effort you put into them! Best regards!

  • @gachawings
    @gachawings 2 месяца назад +3

    Is it possible to add animations too with that slider? I mean that looks Perfect to use, but ig its only for low scale products, or maybe someone who is really into that effect...😊
    But i wanted to do with some good animation effects too for my new project, was thinking if its doable and well u did show me a new way to do.
    Ig i will try this and maybe find if i can do changes to suit my style...😂
    Thanks lun ❤✨

  • @sujitprasadkushwaha9031
    @sujitprasadkushwaha9031 2 месяца назад

    This was really awesome.
    By understanding this logic I feel now that I can make a carousel according to my need because carousel is one my weak spot where I do not shine.
    Thank you for your videos.
    I really love your voice over in your videos also it really make me attentive and don't make me think twice or thrice cause I get it in the first place.
    Keep it up.
    Always waiting for your new videos. 💌💌💌

  • @PicSta
    @PicSta 2 месяца назад

    Amazing slider and soo soo simple. Thanks man. Liked as always.

  • @Meco_1164
    @Meco_1164 2 месяца назад +1

    Thanks man came first to watch this 😅❤

  • @FACKDAWURLD
    @FACKDAWURLD 2 месяца назад

    Simplicity of this is insane! Awesome tip. Is there a way to style the transition? Maybe so it actually looks like it’s sliding?

    • @isaacvr
      @isaacvr 2 месяца назад

      Yes. You can use the Web Transition API to let the browser handle the transition for you, with a couple lines more.

  • @deeeexc
    @deeeexc 2 месяца назад +1

    great work. But now how can you do it that it is no longer an infinite slider?

  • @ASulaymon
    @ASulaymon 2 месяца назад

    that's great. You always help me to make projects bro 🔥🔥🔥

  • @Pixelyze-tech
    @Pixelyze-tech 2 месяца назад +1

    I think the biggest issue is how to animate this correctly so it slides or fades from both sides. Would be great if you can do tutorial on animation with CSS like correctly targeting the right elements and explaining the logic.

    • @SergeyNeskhodovskiy
      @SergeyNeskhodovskiy 2 месяца назад

      The catch is that you can't animate this or apply a transition to this. Transitions are applied to properties and this trick does not deal with any properties so oops

    • @Pixelyze-tech
      @Pixelyze-tech 2 месяца назад

      @@SergeyNeskhodovskiy You can animate, is just targeting the right properties.

    • @SergeyNeskhodovskiy
      @SergeyNeskhodovskiy 2 месяца назад

      @@Pixelyze-tech What property will we be using in this case?

    • @Pixelyze-tech
      @Pixelyze-tech 2 месяца назад

      @@SergeyNeskhodovskiy You can't animate display none as it takes the element out of DOM so that needs to be set to visibility and what I mean by properties is child element in CSS and HTML.

  • @virenkhokhar6305
    @virenkhokhar6305 2 месяца назад

    Your videos are also unique 🎉

  • @berdinazarov6972
    @berdinazarov6972 2 месяца назад

    It is very helpful, thanx a lot❤️

  • @SheriffKoder9
    @SheriffKoder9 2 месяца назад

    Love it. Thank you!

  • @Trendi_Vibes
    @Trendi_Vibes 20 дней назад

    Sorry bro, I am just able to give one like 😢 , your content is next level 👌 💯 👍 😌

  • @callowindia
    @callowindia 2 месяца назад

    Which browser you are using because last mock up are great and i also want to test my website responsiveness

  • @herosova
    @herosova 2 месяца назад

    this is amazing i was trying to simplify slider but you did it like hold my beer

  • @shubhampal5633
    @shubhampal5633 2 месяца назад

    Bro it is amazing video for me and i want to know which extension you used to view on different devices in this video 😊

  • @userTarasK
    @userTarasK 2 месяца назад

    Very cool video, thanks,🤟💪. But how to add smoothness or animation when changing slides using such a slider implementation?

  • @chetanmajumdar5518
    @chetanmajumdar5518 2 месяца назад

    What an idea sir ji 👏👏👏👏

  • @farooghahsan1412
    @farooghahsan1412 2 месяца назад

    thanks bro u done a huge favor
    please also do animation using framer-motion

  • @AttachmentStudios
    @AttachmentStudios 2 месяца назад

    Wow, I learned something new today

  • @timirbarangayen625
    @timirbarangayen625 2 месяца назад

    Keep posting all these dude❤

  • @inseries9068
    @inseries9068 Месяц назад +1

    love you sir

  • @omni2852
    @omni2852 2 месяца назад

    At 4:37 is that an extension? Those phone sizes, i know the dev tools has it but this one looks different

  • @wassim2863
    @wassim2863 2 месяца назад

    bro can you talk about Rive !! , i love your content ❤

  • @ibraheemmudasser4810
    @ibraheemmudasser4810 2 месяца назад +1

    thanks i want this video highly appreciate your content and poo voice in editing🤣

  • @meetgovindbajaj
    @meetgovindbajaj 2 месяца назад

    Can we also add transition animations to it?

  • @SF2-f8p
    @SF2-f8p Месяц назад

    Wow, Thanks alot bro, btw which emulator are you using in chrome

  • @qweasdzxcms
    @qweasdzxcms 2 месяца назад

    Thanks man that's interesting.. how do we make the slider move smoothly?

  • @sasinduadithya6245
    @sasinduadithya6245 Месяц назад

    Thank You Lun Dev Code .....

  • @ahtishamchaudhary436
    @ahtishamchaudhary436 2 месяца назад

    Amazing bro btw which theme are you using?

  • @sachindeveloper831
    @sachindeveloper831 2 месяца назад

    Omg 😮😮😮😮❤❤❤, it took 5 years to me to reach you finally I can sleep peacefully now 😢😢😢❤❤❤

  • @JanMitLuca
    @JanMitLuca 2 месяца назад

    Awesome! Now add transitions and we're all set!

  • @ahammedshajmeer
    @ahammedshajmeer 2 месяца назад

    Can you share what extension used in the last to check responsiveness.

  • @qklduh18d9
    @qklduh18d9 2 месяца назад

    Amazing!!! Thanks a lot

  • @mr_lunatic_77
    @mr_lunatic_77 2 месяца назад +1

    Does this approach limit the ability to animate it or is there a work around?

    • @Saulbez
      @Saulbez 2 месяца назад

      That is what I would like to know, I just managed to use for multiple items, however I cannot figure out how we could create a slide animation..

  • @zainuldin9095
    @zainuldin9095 2 месяца назад

    you can also use index and then % on it and can you show us how to apply animation to this

  • @prajapati.19
    @prajapati.19 2 месяца назад

    Bro you use which theme in vs code I really like it

  • @satyeshnmerwade5029
    @satyeshnmerwade5029 2 месяца назад

    Hey, can I know the name of the chrome extension used in the end of this video that you used to display the developed website in different screen sizes?
    Thank you in advance.

  • @sahilthapamagar8235
    @sahilthapamagar8235 2 месяца назад

    I would like the ask something, Before that I love your video sir. I would like to ask why don't you use the framework like Bootstrap or tailwind css in your video?

    • @lundeveloper
      @lundeveloper  2 месяца назад

      I do use it, I always have many videos with different topics: CSS Only, Bootstrap, tailwindcss, Javascript tutorial, ThreeJs, Gsap,...

  • @hemantduttacodes
    @hemantduttacodes 2 месяца назад

    Try using Audacity to clean up the audio a little bit, it sounds distorted.

  • @AghaHussain-i3f
    @AghaHussain-i3f 2 месяца назад

    How we can add a animation on this slide like a slide or fade animation.Do we use css or javascript for the animation?

  • @virenkhokhar6305
    @virenkhokhar6305 2 месяца назад

    Great 🎉

  • @CodewithIk1177
    @CodewithIk1177 2 месяца назад

    Sir please create one project on react js and using the vite framework ❤❤

  • @groovebird812
    @groovebird812 2 месяца назад

    Hi, could you make a video how we can handle the hover effect on mobile devices?

  • @manthankanani188
    @manthankanani188 2 месяца назад

    Can you please help with the carousel the same way? It should pause on the interactions, with time function, autoplay slide in just 5 lines. I know the same we can do in the same way.

  • @dhanush21128
    @dhanush21128 2 месяца назад

    How to change the mobile or tab background? Do you have used which software

  • @huus5682
    @huus5682 2 месяца назад

    you dont have to upload everyday, but every 1 hour😁

  • @CalyHache-sn8pe
    @CalyHache-sn8pe 2 месяца назад

    Can you make a video about a modern border raduis style ? Please 🥺

  • @topalek
    @topalek 2 месяца назад

    awesome info, thx

  • @leaovulcao
    @leaovulcao 2 месяца назад

    Awesome!

  • @utsavjaiswal007
    @utsavjaiswal007 2 месяца назад

    Good One... Can you tell me what's that extension in which you see responsiveness ?

    • @Hieupv2412
      @Hieupv2412 2 месяца назад

      Mobile simulator - responsive testing tool

  • @techigniteyt
    @techigniteyt 2 месяца назад

    Very good L'un dev❤

  • @donaldpetervicente8351
    @donaldpetervicente8351 2 месяца назад

    is it possible to work with other tags? or just an image? ill experiment later if its work. 😅

  • @Respectgod2
    @Respectgod2 2 месяца назад

    Sir please make a website that no one thought so as a college student we can practice some really new project

  • @prithivimagar126
    @prithivimagar126 2 месяца назад

    Nice video ❤❤❤

  • @fer.guitar
    @fer.guitar 2 месяца назад

    Great vid!

  • @yurikamaha6433
    @yurikamaha6433 Месяц назад

    Fantastic

  • @ZhengChooZhengYouTube-yj7gj
    @ZhengChooZhengYouTube-yj7gj 2 месяца назад

    What is that tools to test responsive screen?

  • @budosfasz
    @budosfasz 5 дней назад

    How did you do the button css?

  • @teckycat7858
    @teckycat7858 2 месяца назад

    which theme you used in visual studio code

  • @btsarmyind-zt4ru
    @btsarmyind-zt4ru 2 месяца назад

    Thanks ❤

  • @kirillzlobin7135
    @kirillzlobin7135 2 месяца назад

    Did this channel had more videos? On the banner it is 2000+

  • @MuhammadAdnan2.0
    @MuhammadAdnan2.0 2 месяца назад

    What about transition for slides ?

  • @Migueltorrejas-el7jd
    @Migueltorrejas-el7jd 2 месяца назад

    bro how you check the responsiveness of your product what extension did you use?

    • @joel-rg8xm
      @joel-rg8xm 2 месяца назад

      I'm guessing it's a Chrome extension called MOBILE SIMULATOR

  • @ukeshrestha
    @ukeshrestha 2 месяца назад

    What are you using to emulate all those devices?
    BTW awesome video!

    • @vinayjhalani139
      @vinayjhalani139 2 месяца назад

      it's a extension named as "Mobile simulator - responsive testing tool"

  • @gokulkkd
    @gokulkkd 2 месяца назад +1

    Video is amazing, can u please give me the plugin name used for the responsive views

    • @Warface
      @Warface 2 месяца назад

      It's "Mobile simulator - responsive testing tool"

    • @gokulkkd
      @gokulkkd 2 месяца назад

      @@Warface where do I can download?

    • @gokulkkd
      @gokulkkd 2 месяца назад +1

      @@Warface thank bro got it in chrome webstore

    • @Warface
      @Warface 2 месяца назад +1

      @@gokulkkd Love the fact that my comment where to download got deleted...

    • @lundeveloper
      @lundeveloper  2 месяца назад

      @@Warface I don't do that 😐 😥😥

  • @diogogptb
    @diogogptb 2 месяца назад

    Can we animate the transition on this logic?

  • @AsafBilal-tn4ub
    @AsafBilal-tn4ub 2 месяца назад

    I love you bro ❤

  • @ibraheemmudasser4810
    @ibraheemmudasser4810 2 месяца назад +1

    thanks

  • @MDHabibulIslamHredoy
    @MDHabibulIslamHredoy 2 месяца назад

    Why don't you make a course end front end development in detail?

  • @tanim_mahbub
    @tanim_mahbub 2 месяца назад

    Awesome!
    I tried it with opacity, visibility, and transition, the NEXT items are getting the transition but the PREV items are not, any idea why?

    • @iamarbazmulla
      @iamarbazmulla 2 месяца назад

      please share your code here lets analyze it

    • @tanim_mahbub
      @tanim_mahbub 2 месяца назад

      @@iamarbazmulla I tried to share the Codepen link, but RUclips is not allowing it.

    • @enkvadrat_
      @enkvadrat_ 2 месяца назад

      @@tanim_mahbub write you codepen username and your id. Then we can assemble the link

  • @uni_media
    @uni_media 2 месяца назад

    Can you do detail playlist beginniler ti advance three js

  • @matthewrittenhouse1387
    @matthewrittenhouse1387 2 месяца назад

    @4:37 what is that on the right?