I have made a page, where if the user update its form, the backend will send the user back to the form with a message like this:


On the index.php site, it loads this:

if(isset[$_GET['msg'] {
$message = 'Updated';
echo '<div class="update_message">'.$message.'</div>';

This works fine, but I would like the message to fade out after a couple of seconds. I tried this, but wouldn't fade out:

if(isset[$_GET['msg'] {
$message = 'Updated';
echo '<div class="update_message">'.$message.'</div>';
echo "<script type='text/javascript'>
$(function() {

The message still apears but it doesn't fade out.


You're using a jQuery snippet but have you actually loaded the jQuery library?

You can do do by using: JHtml::_('jquery.framework');

Here is the updated code with some modifications:

$msg = JFactory::getApplication()->input->get('msg');

if (isset($msg))
    echo '<div id="update_message">Updated</div>';

        jQuery(function($) {

Hope this helps

  • Should this still be inside a <script> ? Haven't worked with jQuery ever :D Jun 15 '18 at 9:30
  • Arh I made it work :) Only thing I needed to edit, was the " instead of ' after addScriptDeclaration( and again at last :) Jun 15 '18 at 9:34
  • No need to use a <script> tag here as the addScriptDeclaration function will automatically insert it inside that tag for you ;)
    – Lodder
    Jun 15 '18 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.