I have checkbox with input fields. When checkbox is clicked then related input field opens and type some text in input. But when I uncheck the checkbox then text from related input should be blank.
<?php
$result = $obj->show_social_icons();
foreach($result as $row)
{
?>
<input type="checkbox" class="maxtickets_enable_cb" name="opwp_wootickets[]" value="<?php echo $row['id']; ?>">
<?php echo $row['name']; ?>
<div class="max_tickets">
<input type="text" name="link[]" class="link">
</div>
<br>
<?php } ?>
My jquery is:
jQuery(document).ready(function($) {
$('input.maxtickets_enable_cb').change(function(){
if ($(this).is(':checked'))
$(this).next('.max_tickets').show();
else
$(this).next('.max_tickets').hide();
}).change();
});
When I uncheck the checkbox then related input filed should be blank or erase. It is not happening. Please help.