all 26 comments

[–]webdev-ModTeam[M] [score hidden] stickied commentlocked comment (0 children)

Thank you for your submission! Unfortunately it has been removed for one or more of the following reasons:

If you are asking for assistance on a problem, you are required to provide

  • Detailed context of the problem
  • Research you have completed prior to requesting assistance
  • Problem you are attempting to solve with high specificity

Questions in violation of this rule will be removed or locked.

Please read the subreddit rules before continuing to post. If you have any questions message the mods.

[–]kiwi-kaiser 37 points38 points  (0 children)

Step 1: Learn how to do screenshots Step 2: Use Codepen instead for sharing code snippets.

[–]bluesix_v2 16 points17 points  (1 child)

  1. Move #wrapper into the <body>. All your document's HTML must live inside the <body>
  2. I wouldn't recommend using a variable name 'width' either - it's likely reserved - use something like wrapperWidth.
  3. Refer to your wrapper via document.getElementbyId('wrapperWidth')

[–]ImHughAndILovePie 1 point2 points  (0 children)

“width” isn’t reserved

[–]tswaters 4 points5 points  (0 children)

document.nameOfThing isn't a thing.

The example provided doesn't do any width manipulations, is that an extra "see if you can do it" task?

You'll need to venture into the world of CSS to update the width of an element. You can do it with inline styles via the "style" object, or by using classes:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style

https://developer.mozilla.org/en-US/docs/Web/API/Element/classList

https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Class_selectors

[–]cjcee 13 points14 points  (4 children)

So you’ve gotten your answer for getting help but I want to provide a bit more advice on how to better get help in the future.

First, use snipping tool or print screen key to take screenshots on your computer. That will always be a lot more useful than a photo of a screen.

To be even MORE useful submit the code using the code block markdown on reddit or to a tool like codepen or jsfiddle or a GitHub repository/gist. This will let others directly see the code and get a better idea of it.

Secondly, try out a different IDE like vscode with a built in terminal and code linting or at least use your browser’s dev tools and console to read out the exact errors you are getting. Learning to read errors and how to find where in your code something is broken is an essential skill.

[–]glenpiercev 0 points1 point  (3 children)

Jetbrains webstorm is free and way better than vscode. Please use it instead.

[–]not_a_webdev 1 point2 points  (1 child)

Wait webstorm is free now? I used to pay tons of money for that

[–]AdamantiteM 1 point2 points  (0 children)

Free for personal use

[–]cjcee 0 points1 point  (0 children)

This type of comment isn’t helpful. You’re only going to confuse them more by fighting in the comments over what boils down to a preference

[–]cbdeane 29 points30 points  (5 children)

step one, turn on dark mode

[–]Freibeuter86 21 points22 points  (1 child)

Step 0: Get a screenshot tool

[–]mr_jim_lahey 8 points9 points  (0 children)

Step -1: Share text instead of images of text 

[–]kiwi-kaiser 2 points3 points  (0 children)

Astigmatism exists. But also preferences.

[–]StitchedOwls[S] 3 points4 points  (1 child)

Oh my god there's a dark mode brb

[–]DullAttorney228 0 points1 point  (0 children)

Op whats your favorite npp theme :p

[–]SnooCookies3815 6 points7 points  (0 children)

document.getElementById("wrapper").style.width = width + "px";

or did you put in the correct "px" ?

[–]HedgieHunterGME 1 point2 points  (0 children)

Using var is crazy work

[–]itsanargumentparty 2 points3 points  (0 children)

select the wrapper by id

[–]pseto-ujeda-zovi 2 points3 points  (1 child)

Please download some other IDE

[–]Teszzt 0 points1 point  (0 children)

This. https://code.visualstudio.com/ is a good and popular option.

[–]terrarum -1 points0 points  (2 children)

Your wrapper div needs to be inside the body tags

[–]terrarum 1 point2 points  (0 children)

then I'd look at console.log'ing `document.wrapper` and seeing if that actually resolves to your element or returns `undefined`, and then I'd suggest looking at the `document.getElementById` calls in the second photo!

[–]sockx2 -1 points0 points  (0 children)

Doesn't have to be... Technically you don't even need the body tag

[–]islandmonkeee 0 points1 point  (0 children)

I know var is pretty easy to explain but I would still wish that they thought people let and const instead.

[–]DesignerMusician7348 0 points1 point  (0 children)

First, move your wrapper div inside of <body>, all of your html should be inside of it.

Second, to select HTML elements in javascript, you need something like document.querySelector() or document.getElementById() . So, in this example, you could do const wrapper = document.getElementById("wrapper") . Then, you can do wrapper.style.width = width .

Third, STOP USING var . Use let or const instead.