Why can I not trigger an input from checkbox label?
Hello,
after three day of searching I still not know why I can not trigger an input field(for use of virtual keyboard) from a checkbox label.
Can someone explain me what i am doing wrong?
Html:
- <div>
- <label for="checkbox-0">I agree<input type="checkbox" name="checkbox-0" /></label>
- <div><input name="test" type="number" id="amount_checkbox-0"></input></div>
- </div>
Script:
- $(function() {
- $('label').click(function() {
- labelID = $(this).attr('for');
- alert($('#amount_'+labelID).attr("name")); //working
- $('#amount_' + labelID ).trigger("click"); //only working on pc
- });
- });
Goal: Press on the label of checkbox, Checkbox will be checked and input must be clicked so that the virtual keyboard of the phone will be displayed.
Thanks in advance