AJAX and events
AJAX and events
Hi. I have a div set to display: none. When a checkbox on the form is checked, I'd like the div to appear.
I was able to do this without a problem using jQuery.
Then I decided to load the form into a page via AJAX instead (I have reasons for this, though I can't guarantee they are GOOD reasons. :-))
Now I can't get that div to appear when the checkbox is clicked.
The "main" page is foo.php.
Depending on the nav selection you select, it pulls in the form. In this case it's bar.php.
Here's my code in foo.php:
<script type="text/javascript">
// Added for context-sensitive checkboxes
$(document).ready(function() {
$('#myDiv').change(function() {
if (this.checked) {
$("div#myDiv").removeClass('display-none');
}
else {
$("div#myDiv").addClass('display-none');
}
}).trigger('change');
});
</script>
I think the problem is that it runs that code and THEN pulls in bar.php. I think I need to figure out the timing of this.
Does my question make sense? Is there a way to do this?
Thanks!