Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Kevin O'Donoghue
Kevin O'Donoghue
8,995 Points

Can someone show me how to write this in vanilla js?

Hi i have this query code and need it in regular old javascript but i have no idea how to do it. I'e looked at the query source and am lost. Thanks to anyone who can assist

function ldr() {
    $.fn.ldrAni = function () {
            opacity: '1'
        }, 250).animate({
            marginTop: '-10px'
        }, 250).animate({
            marginTop: '8px'
        }, 250).animate({
            marginTop: '3px'
        }, 100);

    setTimeout(ldr, 1800);
Andrew Shook
Andrew Shook
31,709 Points

Can I ask why you want to use plain JS instead of using jQuery?

Andrew McCormick
Andrew McCormick
17,730 Points

I'm not a JS expert, but I think this would have to be a pretty extensive answer. One line of Jquery doesn't equal just one line of javascript (it could take many many lines to replicate what you are doing in a line of JQuery). That being said, if you really want help, break it down into pieces. Look at the animate() function in the Jquery library (which I think you have done). Try to replicate it in JS, then come back and post what you have tried and what you have questions about. This question is just way to broad as is.

Here's a quick example of someone trying to figure how to animate opacity in vanilla js. Hope that helps get you started.