My parent div contains a hidden form element (input):
$(document).ready(function () {
$('.parent').on('click', function (event) {
$(this).toggleClass('active');
$(this).find('.child').trigger('click');
});
$('.child').on('click', function (event) {
var theMsg = event.altKey ? 'true' : 'false';
$('.parent span').html(theMsg);
});
});
.parent {
width:100px;
height: 100px;
background: #eee;
}
.child {
display:none;
}
.active {
background: red !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class='parent'>
ALT: <span> </span>
<input class='child'>
</div>
When my parent click handler is invoked, I pay attention to whether ALT key is pressed. I'm trying to trigger('click') for the hidden input element, and pass the altKey status along. Nothing I've tried makes that happen. What am I missing?