JSFiddle - React, Tailwind, and code Playground
HTML
<div class="clickme">Optional</div>
<div class="submit">Submit me</div>
CSS
.clickme, .submit {height:100px; width:100px; line-height:100px; text-align:center; margin:10px;}
.clickme { background:red;}
.submit { background:green; }
JavaScript
// I have two functions and i want to start the second function based on the click event, if the first function returns 0 that means click to start the second function, and if not to start it but with different parameters
var the_action = function(type) {
switch(type) {
case 'a':
console.log('Case A');
break;
case 'b':
console.log('Case B');
break;
}
};
$('.clickme').click(function() {
console.log('Clicked');
$(this).data('clicked', true);
});
//$('.submit').click(function() {
if($('.clickme').data('clicked') == true) {
the_action('a');
} else {
the_action('b');
// }
});