title: can we use js variable name as class name in html
body: <p>I want to concatinate class name with variable count which keep getting updated after each button click, for which I am getting error as &quot;citysName is null&quot;. can anyone suggest</p>
  <pre><code>button.addEventListener('click', resp =&gt; {
      count = count +1;
      var card = document.createElement('card');
      card.innerHTML = `
                  &lt;img src=&quot;...&quot; class=&quot;card-img-top&quot; alt=&quot;...&quot;&gt;
                  &lt;div class=&quot;card-body&quot;&gt;
                    **&lt;h5 class=&quot;card_title&quot; + count&gt;&lt;/h5&gt;
                    &lt;h6 class=&quot;temp&quot; + count&gt;&lt;/h6&gt;
                    &lt;p class=&quot;card-text&quot; + count&gt;&lt;/p&gt;**
                    &lt;a href=&quot;#&quot; class=&quot;btn-primary&quot;&gt;&lt;/a&gt;
                  &lt;/div&gt;
      `;
      card.className = 'card';
      var content = document.getElementById('id1');
      content.appendChild(card);
      **var citysName = document.querySelector('.card_title'+count);
      var description = document.querySelector('.card-text'+count);
      var temp = document.querySelector('.temp'+count);**
      fetch('https://api.openweathermap.org/data/2.5/weather?q='+inputVal.value+'&amp;appid=a5599c020b0d897cbc8b52d547289acc')
      .then(post =&gt; post.json())
      .then(data =&gt; {
          var cityName = data['name'];
          var temper = data['main']['temp'];
          var descrip = data['weather'][0]['description'];
  
          let ctemp = Math.round(temper-273);
          citysName.innerHTML = cityName;
          temp.innerHTML = ctemp + &quot;°C&quot;;
          description.innerHTML = descrip;
      })
  })
  </code></pre>