You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用JavaScript修改输入框值?Chrome开发者工具修改失效求助

I’ve dealt with this exact frustration on Upbit’s trading interface before—those modern front-end frameworks don’t let you just tweak DOM values willy-nilly. Let’s break down why your attempts aren’t sticking and how to actually make it work.

Why Direct DOM Edits Fail

Upbit uses a framework like React to power its interface, where the input’s displayed value is tied to the framework’s internal state, not just the raw DOM value property. When you edit the value in DevTools, you’re only updating what’s visible in the DOM, not the underlying state the app uses to process your input. On top of that, there are likely input or change event listeners that validate or sync the value—these don’t fire automatically when you manually edit the DOM.

Solution 1: Simulate Real User Input (Most Reliable)

The best way to get the app to recognize your change is to mimic exactly what a human user does: set the value, then trigger the events the framework is listening for. Here’s how to do it in Chrome DevTools’ Console:

  1. Grab the input’s selector: Go to the Elements panel, find the input box (e.g., price or quantity for KRW-BTC), right-click it, and select Copy > Copy selector to get an accurate CSS selector.
  2. Run this script in the Console:
// Replace with your copied selector (e.g., 'input[placeholder="가격 입력"]')
const inputElement = document.querySelector('YOUR_COPIED_SELECTOR');

if (inputElement) {
  // Set your desired value (e.g., '50000000' for 50M KRW)
  inputElement.value = 'YOUR_TARGET_VALUE';
  
  // Trigger the input event (React and similar frameworks listen for this to sync state)
  inputElement.dispatchEvent(new Event('input', { bubbles: true }));
  
  // Optional: Trigger the change event if the app uses it for final validation
  inputElement.dispatchEvent(new Event('change', { bubbles: true }));
}

This should sync your value to the app’s internal state, making it recognize the change just like if you typed it manually.

Solution 2: Modify the Framework’s Internal State (Advanced)

If the first method doesn’t work (rare, but possible), you can directly edit the framework’s state. For React-based sites like Upbit:

  • Install the React DevTools extension for Chrome.
  • Open DevTools, switch to the Components tab, and find the component that controls the input (look for state variables like price or quantity).
  • Edit the state value directly in the React DevTools—this will automatically update the input and the app’s state.

Note: This method is less reliable over time, since Upbit might change their component structure with updates.

Critical Notes
  • Upbit has anti-automation safeguards. Repeatedly using scripts to modify inputs could lead to account restrictions, so only use this for learning purposes.
  • Always test with non-transactional changes first to avoid accidental trades!

内容的提问来源于stack exchange,提问作者PEPE BIT

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:08:30