How would i go about readying these functions for use in a page?

How would i go about readying these functions for use in a page?

I'm a bit of a noob, so my code is quite experimental at the moment and all over the place.

I found some code that looked better organised - my flavour of it is shown below, but I'm unsure how to trigger it in the page/document.ready function.

Anyone help?

  1. vouchers = {
        init: function () {
           
            vouchers.attachHandlers();
        },
        attachHandlers: function () {
           
            $('body').on('click', '.click-reveal', revealCode);

            function revealCode (e) {
                pd(e);
                $(this).attr('href', $(this).data('url'));
                window.open(e.currentTarget.href, 'out');
            }
        }
    };