V
V
Vladimir Zuev2020-07-19 11:33:20
Google Apps Script
Vladimir Zuev, 2020-07-19 11:33:20

How to get an element in the sidebar?

Hello.
How to get element in index. html by its id or class?
I've tried that and it doesn't work. How to get this element correctly? Please help. index.html code
const models = document.querySelector(".models");
var doc = DocumentApp.openById(".models");

<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
  <?!= include('styles') ?>
  <h1 style="text-align: center;">Шаблоны</h1>
  <div class="parent models" style="margin:0 auto; width:290px" > 
  <br>  
      <div id="color" style="margin:0 auto; width:290px">
           <?!= include('picker') ?>
      </div>
  </div>
<script>
function createModel(){
 
     const models = document.querySelector(".models");
     var doc = DocumentApp.openById(".models");
     alert('doc =', doc);
     console.log(models);
     //Logger.log('models =',models);
     let col_value = document.getElementById("color-result-nameID").textContent;
     let col_text = document.getElementById("color-result-text_col").textContent;
     let profit_ratio = document.getElementById("profit_ratio").value;
     let manager_ratio = document.getElementById("manager_ratio").value;
     let ad_ratio = document.getElementById("ad_ratio").value;
     let n = document.getElementById("color-result-divn").textContent;
     document.getElementById("color-result-divn").textContent = n+1;
     console.log("manager_ratio = ", manager_ratio);
       const model = `
       <div id = "child-${n+1}"; class="child">
         <div  class="child-1" style="background: ${col_value}">
            <p class="collor-text" style="color: ${col_text}" >Цвет текста<span class="letter" onclick="closeDiv(this.closest('[id^=child]'))">&#215</span></p>
         </div>
         <p style="color: ${col_value}">Кф. прибыли
            <p class="color-kf">${profit_ratio}</p></p>
         <p style="color: ${col_value}">Кф.менеджера</p>
         <p class="color-kf">${manager_ratio}</p></p>
         <p style="color: ${col_value}">Кф. рекламы</p>
         <p class="color-kf">${ad_ratio}</p></p>
      </div>
       `;
       
   // models.insertAdjacentHTML('afterbegin', model);
   };
  
function getData(){
  var hex_col = document.getElementById("color-result-hex").innerText;
  var name_col = document.getElementById("color-result-name").innerText;
  var txt_col = document.getElementById("color-result").style.color;
var color = [hex_col, name_col, txt_col];
// google.script.run.withSuccessHandler().receiveData(color);
function closeDiv(el){
      el.parentNode.removeChild(el);
      }
};
</script>
</body>
</html>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mityayka1, 2020-07-19
@vladd56

document.querySelectorAll

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question