-1

I have a problem with calling the appropriate parameters for my function from this DOM:

data
    weather:Array(1)
       0: {id:800, main:"Clouds", description: "few clouds", icon: "02n"}

I write this (but it doesn'work):

$(".myClass").html(data.weather:Array(1).0.description);

How I must write this code to get description?

buka korek
  • 49
  • 3
  • 7
  • `data.weather[0].description` – Barmar Oct 22 '20 at 20:49
  • `:Array(1)` is not part of the property name, it's just the console telling you that the value of the `weather` property is an array with 1 element. – Barmar Oct 22 '20 at 20:50
  • Note that DOM is short for Document Object Model and is specific, in the web dev context, to the object model exposed to programming languages of the HTML or XML document loaded into memory. What you are showing there could be termed an object model, but not DOM. – Heretic Monkey Oct 22 '20 at 20:54

1 Answers1

1

You were not accessing array properly. Try it.

$(".myClass").html(data.weather[0].description);
mr hr
  • 3,162
  • 2
  • 9
  • 19