JSFiddle - React, Tailwind, and code Playground
HTML
<div>
<button class='step' type='button'>
Step 1
</button>
<button class='step' type='button'>
Step 2
</button>
</div>
JavaScript
jQuery(document).ready(function( $ ) {
const form = {
init: function() {
$('.step').on('click', () => this.hello())
},
hello: function() {
console.log('Index: ', $(this).index()); // I can get the right index
this.hi(); // ERROR: Hi is not a function!
},
hi: function() {
console.log('HI')
},
}
form.init()
})