John Davidson

javascript - The value of my variable is changing In another file

0 comments
Message:


I got this varible:


var things = $('#box li');

My problem is that the user can change the value in #box. So it contains x different li:s then my var things is not set anymore. How do I change this var? var things is in my index.php file. The place where the user changes the #box is in my change.php file, so I think It's a bit harder.


Probably I duplicate but I dont know what to search so please direct me if you can.



My Answer:
#things');

In another file, if you want to access the value of the 'things' variable, you can do so by importing the file where the variable is declared and then accessing the variable like this:

javascript
import { things } from './file.js';

console.log(things);


This will log the value of the 'things' variable to the console. Make sure to replace 'file.js' with the actual file path where the variable is declared.

Rate this post

5 of 5 based on 8505 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us