JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<input type='image' src='//placehold.it/80x20' class='heads'></input>
<br/>
<p><strong>Result:</strong></p>
<p id="myP"></p>
<!-- If you wish to keep the Javascript inline instead of external you will need to wrap it in a <script> tag -->
<script>
$(document).ready(function(){
function coin(){
return Math.random();
}
function toss(coin){
if (coin > .5 ){
$('#myP').text('heads!');
} else if (coin <= .5) {
$('#myP').text('tails!');
} else{
console.log('error');
}
}
$('.heads').on('click', function() {
toss(coin());
});
});
</script>