I'm trying to insert javascript into a div. All of this is within a php document.
I am trying to get a div to fade into view when it's child div is loaded. Parent div had id of 'subemail' (this is hidden) Child div with id 'error' is shown then it should fade in the above div.
Following is the script I'm trying to load but get error unexpected T_STRING, expecting ',' or ';'.
<script type="text/javascript">
$(function(){$('div#subemail').fadeIn('slow');});
</script>
The PHP document:
if (empty($_POST['sub_name'])) {
$errors[] = 'Please type in your name';
} else {
$sub_name = strip_tags($_POST['sub_name']);
}
if (filter_input(INPUT_POST, 'sub_email', FILTER_VALIDATE_EMAIL)) {
$sub_email = $_POST['sub_email'];
} else {
$errors[] = 'Please type in a valid email';
}
if ($errors) {
echo '<div class="errors">';
echo '<script type="text/javascript">';
echo '$(function(){$('div#subemail').fadeIn('slow');});';
echo '</script>';
foreach ($errors as $error) {
echo '<p class="error">- ' . $error . '</p>';
}
echo '</div>';
}