Declare jquery as a dependency and wrap your code in a function. WordPress runs jQuery in noConflict mode, so $ is not available globally.
functions.php
function lotgrafix_enqueue_jquery_script() {
wp_enqueue_script( 'lotgrafix-main', get_template_directory_uri() . '/js/main.js', array( 'jquery' ), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'lotgrafix_enqueue_jquery_script' );
main.js
jQuery( function ( $ ) {
$( '.my-button' ).on( 'click', function () {
$( this ).toggleClass( 'active' );
} );
} );