I'm trying to do some javascript work on this example:
var str= '<td><input id="product" type="checkbox" name="product' + i + '" value="Yes" /> new product?</td>';
str = str+'<td><input type="text"class="form-control" id="number ' + i + '" name="number' + i + '" placeholder="GTIN"</td>'
<script>
$(document).ready(function () {
var ckbox = $('#product');
$('input').on('click', function () {
if (ckbox.is(':checked')) {
document.getElementById("number").readOnly = true;
document.getElementById("number").value = "";
} else {
document.getElementById("number").readOnly = false;
}
});
});
</script>
This seems to work only if my input checkbox is outside the string builder