我先寫好一段 xpath 路徑,然後通過該路徑可以查到對應的元素節點。
通過 document.evaluate('...', document).iterateNext()
方法可以用 xpath 路徑定位到元素節點。
> var a = document.evaluate('//*[@fieldid="pk_fct_ap_plan_table"]//*[contains(@class,"table-body")]//table//tr//*[@fieldid="planmoney"]//input', document).iterateNext()
> a
< <input id="test" autocomplete="off" max="100000000000000000000" min="-100000000000000000000" width="120px" attrcode="planmoney" color="#555555" datatype="31" fielddisplayed="refcode" fieldvalued="refpk" itemtype="number" label="計劃金額" position="7" title dataindex="planmoney" order="flatscend" ordernum foolvalue="777.00" type="text" class="nc-input number-formcontrol u-form-control md" value="777.00" style="text-align: right;">
如下圖所示,可以看到我定位到對應的元素節點了。
喜歡的點個贊❤吧!