Quem
Portfolio
Leia
Contato

jQuery in Oxygen

In Oxygen Code Block, you have the option to write jQuery code. But this can be tricky because you can't just copy some code from the internet there. You need to adapt to it first.

Usually, jQuery is defined with a '$' at the beginning of each line, but Oxygen needs it to be 'jQuery' instead. To save some typing, we can declare a function that states that all 'jQuery' will be replaced with a '$'.

In the example below, I show how to do that and execute the code only when the DOM is ready and already loaded.

jQuery(document).ready(function($){
  //your code
});

If you want to make it a bit simpler using a jQuery short-hand, here is how it's done:

(function ($) {
  //your code
})(jQuery);

homeenvelopeuserphone-handsetlaptop-phonetext-align-center
pt_BR
en_US pt_BR
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram