It's a real mystery, but somehow I cannot detect checkbox click or change with the following code:
jQuery(document).ready(function () {
jQuery(document).on("click", "#item_configuration_item_selected", function() {
console.log("click");
});
});
It works with any other element, but not checkboxes.
When I try to detect the clicked element with this:
jQuery('body').click(function(event){
var id = event.target;
console.log(id);
});
then again, it shows a clicked element id for any other element, except checkbox. I'm just going crazy figuring this out.
Element html looks like this:
<div class="span3">
<label for="item_configuration_item_selected" class="checkbox">
<input type="checkbox" class="fabrikinput " name="item_configuration_item_selected[0][0]" id="item_configuration_item_selected" value="1"><span>MyLabel</span></label>
</div>
Any hint would be highly appreciated.
Edit added snippet
jQuery(document).ready(function() { jQuery(document).on("click", "#item_configuration_item_selected", function() { console.log("click"); }); });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <div class="span3"> <label for="item_configuration_item_selected" class="checkbox"> <input type="checkbox" class="fabrikinput " name="item_configuration_item_selected[0][0]" id="item_configuration_item_selected" value="1"><span>MyLabel</span></label> </div>
Thank you all, but Prakash's suggestion "$("#item_configuration_item_selected").change(function() {})" was the only thing that worked. Thank you so much, I'm still confused why, but as long as it does the trick: I can live with that :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.