I am trying to add an inline Javascript in my Joomla 4 plugin using addScriptDeclaration().I edited the code like suggested but the plugin is not working .After enabling it , it is not doing anything .Also I'm confused about the error Uncaught ReferenceError: $ is not defined
<?php
// no direct access
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\CMSPlugin;
class PlgSystemhelloworld extends CMSPlugin
{
public function onAfterDispatch()
{
$result = "girl";
$document = JFactory::getDocument();
$document->addScriptDeclaration(' document.addEventListener("DOMContentLoaded", function()
{
alert(hello + "' . $result . '");
}
);');
}
}
?>
Also, Is there any good tutorials available ?
<head>
or not and get back to me with the answer. How to check your page source in different browsers: neilpatel.com/blog/how-to-read-source-code