Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Recent content by Benny_2306

  1. Benny_2306

    JavaScript Insert classes using JavaScript

    I've fixed both problems now: 1. The pictures didn't load because I defined the wrong path (i used glass.src="glass_empty.jpg" but should have used glass.src="/Pictures/glass_empty.jpg") 2. The <img> element now have the IDs from 0 to 9 instead of 1 to 10 and now it works properly. But once...
  2. Benny_2306

    JavaScript Insert classes using JavaScript

    I've put the onload="init()" on the body but now I have two new problems: 1. When the page is loaded the first time, the images don't load and in the google chrome console is the error message: 2. The last glass isn't doing what it is supposed to do. It is selected even though it...
  3. Benny_2306

    JavaScript Insert classes using JavaScript

    I'm completely lost here. I've been searching the internet for possible solutions for another two hours but if I click a <img> nothing happens. I think I'll just use something simpler like a range input for now and start the JavaScript course on FreeCodeCamp and then come back to this when I...
  4. Benny_2306

    JavaScript Insert classes using JavaScript

    Sorry I copied the wrong code into the html file because in VSC i have seperate files for html and JavaScript. Regarding the <a>, I've tried it without them first but it didnt work. But here's the code I have so far: const glas = document.querySelector('.glas-a')...
  5. Benny_2306

    JavaScript Insert classes using JavaScript

    I think I have figured out how to add an event listener but I don't know how to move on from here. I tried a few things but haven't arrived anywhere that's close to working. Here is the code I have so far: <div class="container"> <a class="anchor"><img src="Glass-std.svg"...
  6. Benny_2306

    JavaScript Insert classes using JavaScript

    Thanks for the information!! I'll try it out let you know my results? :)
  7. Benny_2306

    JavaScript Insert classes using JavaScript

    Yeah no lables. Only the glasses visible/ clickable
  8. Benny_2306

    JavaScript Insert classes using JavaScript

    I am working on a survey site about ones physical health and one question is how much water one drinks. So my idea was that there are water cups and you could select the amount of glasses you drink a day. But if i for example want to select 4 glasses i'd click on glass 4 but all the glasses 1-4...
  9. Benny_2306

    JavaScript Insert classes using JavaScript

    I basically know no JavaScript at all yet i need it for my current project i am working on to learn scss and html. I have a set of radio buttons an what i need is if a radiobutton is checked, that its label and the labels bofre it get a extra class inserted. (e.g. if radiobutton 4 was checked...
Back
Top Bottom