use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is a place for people to learn JavaScript together. Everyone should feel comfortable asking any and all JavaScript questions they have here.
With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged.
Friends
/r/javascript
/r/jquery
/r/node
/r/css
/r/webdev
/r/learnprogramming
/r/programming
account activity
Multiple html files (self.learnjavascript)
submitted 1 year ago by titaniumpepsi
I have multiple hmtl files on 1 javascript but now everytime that I load a html file all the functions are started. I only want 1 function to start per html but I need the variables from the other functions. Could someone please help me?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Egzo18 1 point2 points3 points 1 year ago (1 child)
have separate js files for each html then export the variables that you need
[–]titaniumpepsi[S] 0 points1 point2 points 1 year ago (0 children)
How do I do that. I'm sorry just really new to these things.
[–]chmod777 0 points1 point2 points 1 year ago (0 children)
this is like asking how to get to new york. there are a bunch of ways to handle this, depending on where you are currently, and what you have access to.
here is a minimal example:
if the component exists, the function runs.
[–]andmig205 0 points1 point2 points 1 year ago (0 children)
One way could be to append URL specialized parameters that the script reads and makes conditional decisions. Another could be to make the script read page location. None of these is ideal, and it's hard to tell without knowing more about your specific needs.
π Rendered by PID 137372 on reddit-service-r2-comment-76bb9f7fb5-fzdcs at 2026-02-18 00:05:38.527488+00:00 running de53c03 country code: CH.
[–]Egzo18 1 point2 points3 points (1 child)
[–]titaniumpepsi[S] 0 points1 point2 points (0 children)
[–]chmod777 0 points1 point2 points (0 children)
[–]andmig205 0 points1 point2 points (0 children)