getElementsByClass and appendChild

后端 未结 3 1267
悲哀的现实
悲哀的现实 2021-01-04 04:19

just brushing up on my javascript skills and trying to figure out why getElementsByClass isn\'t working for my code. The code is pretty simple. Upon clicking a button \"cl

3条回答
  •  花落未央
    2021-01-04 04:48

    As you have noticed, the function is called getElementsByName with "elements" being a plural.

    It returns a list of markups by their name (and not their css class).

    You need to use the function that handles the class name, and get the first element of the array, or loop on all the results, depending on what you are looking for.

提交回复
热议问题