Day 4: 100 days of code, innerHTML and innerText difference in JS

gauravshekhawat

Gaurav-Shekhawat

Posted on August 17, 2021

Day 4: 100 days of code, innerHTML and innerText difference in JS

DIfference between innerHTML and innerText in js

see this medium article for details.

This is short summary of the above article.

Difference between getElementById and getElementsByClassName

The difference that I found through trial and error:-

The getElementById will select only one element(as only one element will have that unique id), while in the arguments of getElementsByClassName we can provide multiple classes, and it will select all the elements matching those classes. Hence getElementsByClassName is like an array. Example:-

<div class="parentDiv"></div>
Enter fullscreen mode Exit fullscreen mode

To access the above, you have to write

var divToBeAppended = document.getElementsByClassName("parentDiv");
divToBeAppended[0].appendChild(newButton);
Enter fullscreen mode Exit fullscreen mode

Important things to remember:-

  • centering using margin auto

  • In case of a image as direct child of an div with rounded corners, the image will overflow through the container. To stop that, you can use:-

.container{
overflow:hidden;
}
Enter fullscreen mode Exit fullscreen mode

Things i couldn't make a summary of:-

  • Change button colors project
  • Kotlin basics:- functions, variables, etc.

Things couldn't complete ( try again)

  • CP problem:- Time is Mooney
  • CP DP handbook last section
💖 💪 🙅 🚩
gauravshekhawat
Gaurav-Shekhawat

Posted on August 17, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Day 9: Done React
100daysofcode Day 9: Done React

April 14, 2022

Get Weather {Day -17}
100daysofcode Get Weather {Day -17}

August 30, 2021

Getting Started With API {day -15}
100daysofcode Getting Started With API {day -15}

August 28, 2021