With this code, Firefox alerts on the button click only. For Chrome, both alerts are displayed.
I would like the behavior the same as in Chrome, where an event is triggered by the img when it is clicked (which is ignored by Firefox).
Note: my actual code is much longer and more functional. I distilled it to this smaller set of code to isolate the root behavior that is causing me pain elsewhere.
<html>
<head>
<script src="http://app.essets.com/system/application/js/jquery/jquery.js" type="text/javascript"></script>
<script type='text/javascript'>
$(document).ready(function() {
$('button').click(function(){
alert('button clicked');
});
$('img').click(function(){
alert('img clicked');
});
});
</script>
</head>
<body>
<button type='button'>
<img id="1" class="moduleratingstar" src="http://app.essets.com/images/site/transactions.png">
Some text
</button>
</body>
</html>
I don’t think you will be able to reproduce Chrome’s behavior across browsers – I’m not even sure what the specs says about this.
You could, however, create a “fake” button, that is, using a others HTML elements styled to look like a button. This way, implementing such behavior would be a no-brainer.
Take a look at this fiddle.