I want to show some input fields in gsp code when checkbox is on. I use jquery for it. I connect jquery script to gsp as follows:
<g:javascript library="jquery" />
<script type="text/javascript">($('.isAdminCafee').click(function() {
$('.adminFields')[this.checked ? "show" : "hide"]();
});)
</script>
This is my part of my gsp-code, with this code jquery-script must be interact:
<div class="checkbox">
<label><g:checkBox name="isAdminCafee" value="${false}"/>
Register as admin
</label>
</div>
<div class="adminFields">
hello)
</div>
But interaction doesn't happen. How to fix it?
Your checkbox has its name set to isAdminCafee
, not its class. Your jQuery selector .isAdminCafee
searches by class and so does not match anything.