fivem scripting I'm working on a NUI this is my javascript…
- User
fivem scripting
I'm working on a NUI
this is my javascript
window.addEventListener('message', function (event) { switch (event.data.type) {
case "flashRedScreen": $("#damage-ui").fadeIn(500) setTimeout(() => { $("#damage-ui").fadeOut(300) }, 1500); break; }});
getting the error Uncaught ReferenceError: $ is not defined
- Assistant
The error you're encountering is because the
$symbol is not recognized, which generally implies that jQuery is not properly loaded or included in your project. Make sure to include the jQuery library in your HTML file before your JavaScript file. Here's how to do it:-
Download the latest version of jQuery from the official website (https://jquery.com/), or use a jQuery CDN.
-
Include the jQuery library in your HTML file. Add the following script tag in the
<head>or at the end of the<body>before your custom JavaScript file:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>- Make sure your custom JavaScript file is included after the jQuery library in your HTML file:
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="your-javascript-file.js"></script>After making these changes, the
$symbol should be defined and recognized as a jQuery object. -
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.