Javascript jQuery在某些时候只能在index.html中工作

Javascript jQuery在某些时候只能在index.html中工作,javascript,html,jquery,electron,Javascript,Html,Jquery,Electron,本案: 首先加载index.html的电子应用程序 我有一个带有jquery函数的javascript文件,该文件在数据库中插入数据,并使用sequelize(ID insert): 当我将ID为insert的按钮放在索引html中的这一点上时,它完成了他的工作: <div id="container"> <nav> <div id="buttons"> <div

本案:

首先加载index.html的电子应用程序

我有一个带有jquery函数的javascript文件,该文件在数据库中插入数据,并使用sequelize(ID insert):

当我将ID为insert的按钮放在索引html中的这一点上时,它完成了他的工作:

<div id="container">
  <nav>
      
      <div id="buttons">
          <div id="minimize">
            <span id="minimize-font">&mdash;</span>
          </div>
          <div id="maximize">
            <span id="size-font">&#9723;</span>
          </div>    
          <div id="close">
             <span id="close-font" >&#10005;</span>
          </div>
          <button id="insert" style="margin-top: 120px; color: black; margin-left: 150px; position: absolute; ">TEST</button>
        </div> 
    </nav>
</div> 

&mdash;
◻
✕
试验
但当我将按钮添加到我的newArticle.html时,它不会:

  <div class="box-wrapper"> 
      <div id="articles"> 
          <div class="form">
              <from  class ="übergeben" type="submit">
                <div class= Teilenummer>
                    
                  <label for="Teilenummer">Teilenummer: </br>
              
                  <input type="text" name="Teilenummer" id="Teilenummer" style="height: 30px; width: 300px; background: #2A4A51; border-radius: 6px; border: none;" onClick="this.style.color = 'white'"/><br /><br />
              
                </div> 
                <div class= SKU>
                    
                    <label for="SKU">SKU: </br>
                
                    <input type="text" name="SKU" id="SKU" style="height: 30px; width: 100px; background: #2A4A51; border-radius: 6px; border: none;" onClick="this.style.color = 'white'"/><br /><br />
                    
                  </div> 

                  <div class= Price>
                    
                    <label for="Price">Preis: </br>
                
                    <input type="text" name="Price" id="Price" style="height: 30px; width: 100px; background: #2A4A51; border-radius: 6px; border: none;" onClick="this.style.color = 'white'"/><br /><br />
                
                  </div> 
                <div class= Hersteller>
                  <label for="Hersteller">Hersteller: </br>
                      <select name="Hersteller" id="Hersteller" style="height: 30px; width: 300px; background: #2A4A51; border-radius: 6px; border: none; color: white;">
                          <option value="Volkswagen">Volkswagen</option>
                          <option value="Audi">Audi</option>
                          <option value="BMW" selected="selected">BMW</option>
                          <option value="Mercedes" selected="selected">Mercedes</option>
                          <option value="Opel" selected="selected">Opel</option>  
                      </select>
                  </label>
              </div>
              <div class=Beschreibung var=Beschreibung>
                  <label for="Beschreibung">Beschreibung: </br>
                  <input type="text" name="Beschreibung" id="Beschreibung" onClick="this.style.color = 'white'" style="height: 30px; width: 410px; background: #2A4A51; border-radius: 6px; border: none;" /><br /><br />      
                  </div>
              </form>
          </div> 
          <input id="insert" class="Eintragen-Button" type="submit" value="Anlegen " 
          onclick="values();
          document.getElementById('Teilenummer').value='';
          document.getElementById('Beschreibung').value='';
          document.getElementById('Price').value='';
          document.getElementById('SKU').value=''; "/>
          <span id="response"></span>
          
          
        
          <button class="exportieren" onclick="exportTableToExcel('tblData')">Exportieren</button>
          <button id="insert" class="exportieren">TEST</button>
      </div> 

泰勒努默:


SKU:


Preis:


赫斯特勒:
大众 奥迪 宝马 梅赛德斯 欧宝 贝施雷邦:


出口者 试验

我做错了什么??请帮帮我

这里一个明显的区别是按钮的HTML中有一个巨大的
onclick
属性,这可能会产生一个引用错误。你检查控制台了吗?发布代码时不要共享你的凭据!我可以登录到你的数据库!(什么都没做,如果你真的发布了真实的凭证,我只是个古玩。)谢谢@kopz!这没什么大不了的,只是一个测试数据库,我很快就会删除它,里面没有重要的信息。但是我确实忘了隐藏登录,所以谢谢你的提示!控制台没有给我错误,我尝试不使用onClick来确定。删除onClick并不能解决问题:(
  <div class="box-wrapper"> 
      <div id="articles"> 
          <div class="form">
              <from  class ="übergeben" type="submit">
                <div class= Teilenummer>
                    
                  <label for="Teilenummer">Teilenummer: </br>
              
                  <input type="text" name="Teilenummer" id="Teilenummer" style="height: 30px; width: 300px; background: #2A4A51; border-radius: 6px; border: none;" onClick="this.style.color = 'white'"/><br /><br />
              
                </div> 
                <div class= SKU>
                    
                    <label for="SKU">SKU: </br>
                
                    <input type="text" name="SKU" id="SKU" style="height: 30px; width: 100px; background: #2A4A51; border-radius: 6px; border: none;" onClick="this.style.color = 'white'"/><br /><br />
                    
                  </div> 

                  <div class= Price>
                    
                    <label for="Price">Preis: </br>
                
                    <input type="text" name="Price" id="Price" style="height: 30px; width: 100px; background: #2A4A51; border-radius: 6px; border: none;" onClick="this.style.color = 'white'"/><br /><br />
                
                  </div> 
                <div class= Hersteller>
                  <label for="Hersteller">Hersteller: </br>
                      <select name="Hersteller" id="Hersteller" style="height: 30px; width: 300px; background: #2A4A51; border-radius: 6px; border: none; color: white;">
                          <option value="Volkswagen">Volkswagen</option>
                          <option value="Audi">Audi</option>
                          <option value="BMW" selected="selected">BMW</option>
                          <option value="Mercedes" selected="selected">Mercedes</option>
                          <option value="Opel" selected="selected">Opel</option>  
                      </select>
                  </label>
              </div>
              <div class=Beschreibung var=Beschreibung>
                  <label for="Beschreibung">Beschreibung: </br>
                  <input type="text" name="Beschreibung" id="Beschreibung" onClick="this.style.color = 'white'" style="height: 30px; width: 410px; background: #2A4A51; border-radius: 6px; border: none;" /><br /><br />      
                  </div>
              </form>
          </div> 
          <input id="insert" class="Eintragen-Button" type="submit" value="Anlegen " 
          onclick="values();
          document.getElementById('Teilenummer').value='';
          document.getElementById('Beschreibung').value='';
          document.getElementById('Price').value='';
          document.getElementById('SKU').value=''; "/>
          <span id="response"></span>
          
          
        
          <button class="exportieren" onclick="exportTableToExcel('tblData')">Exportieren</button>
          <button id="insert" class="exportieren">TEST</button>
      </div>