获取查询选择器值d3.js

问题描述 投票:0回答:1

我是d3js的新手。我试图从第二个输入元素获取查询值,我不知道如何去做。

 <div id="rxn-input" style="position: absolute; left: 20px; top: 464px; display: block;">
  <div style="position: relative; outline: 0px; border: 0px; margin: 0px; padding: 0px;">
    <div style="position: absolute; outline: 0px; margin: 0px; padding: 0px; border: 0px; font-size: 13px; font-family: sans-serif; color: rgb(51, 51, 51); background: transparent; top: 0px; left: 0px; overflow: hidden; visibility: visible;"></div>

    <input type="text" spellcheck="false" style="font-size: 13px; font-family: sans-serif; color: rgb(170, 170, 170); background-color: rgb(238, 238, 238); width: 100%; outline: 0px; border: 0px transparent; margin: 0px; padding: 0px; position: absolute; top: 0px; left: 0px; box-shadow: none;">

    <input type="text" spellcheck="false" style="font-size: 13px; font-family: sans-serif; color: rgb(51, 51, 51); background-color: transparent; width: 100%; outline: 0px; border: 0px; margin: 0px; padding: 0px; vertical-align: top; position: relative;">
    <div style="position: absolute; visibility: visible; outline: 0px; margin: 0px; padding: 0px; text-align: left; font-size: 13px; font-family: sans-serif; background-color: rgb(238, 238, 238); z-index: 100; cursor: default; border-style: solid; border-width: 1px; border-color: rgb(170, 170, 170); overflow-x: hidden; white-space: pre; overflow-y: scroll; left: 0px; top: 100%; max-height: 443.016px;">
      <div id="5MTHFt" style="color: rgb(51, 51, 51); background-color: rgb(221, 221, 221);"><b>5MTHFt</b> 5mthf_e ↔ 5mthf_c</div>
      <div id="EX_fol_e" style="color: rgb(51, 51, 51);"><b>EX_fol_e</b> fol_e ↔ <b></b></div>
      <div id="FOLR2" style="color: rgb(51, 51, 51);"><b>FOLR2</b> fol_c + nadph_c → dhf_c + nadp_c</div>
      <div id="FOLt2" style="color: rgb(51, 51, 51);"><b>FOLt2</b> fol_e + oh1_c ↔ fol_c + oh1_e</div>
    </div>
  </div>
  <button class="button input-close-button">×</button>
</div>

以下是我获得价值的尝试:

  console.log("VALUE:"+document.querySelector("#rxn-input input")[1].value);

但是,我得到一个空白值。任何帮助深表感谢。

javascript d3.js
1个回答
1
投票

如果你知道输入将永远是第二个孩子,你可以这样:

const input = d3.select('input:nth-child(2)');
console.log(input.property('value'));
© www.soinside.com 2019 - 2024. All rights reserved.