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

如何通过JQuery查找并禁用Lookup按钮及关联输入框

Fix for Disabling Lookup Button and Text Area
  • Incorrect selector for the lookup button: Your closest(".ew-lookup-list") call isn't finding the right parent element because the hidden input #x_Id_armaster is a sibling of the .ew-lookup-list div, not a child of it. That's why btn.length is likely returning 0—your selector isn't matching any elements.
  • Not properly setting the disabled state: btn.attr("disabled") only retrieves the current value of the attribute, it doesn't set it to disable the button. You need to use either attr("disabled", true) or (preferably) prop("disabled", true) for boolean properties like disabled.

Here's the corrected code that should work:

// Get the lookup button correctly (sibling of the hidden input)
var btn = $("#x_Id_armaster").siblings(".ew-lookup-list").find(".ew-lookup-btn");
// Disable the button
btn.prop("disabled", true);

// Get the visible lookup text div
var lookupText = $("#x_Id_armaster").siblings(".ew-lookup-list").find(".ew-lookup-text");
// Add disabled styling and prevent interaction
lookupText.addClass("ew-disabled").css({
    "pointer-events": "none",
    "opacity": 0.65
});

Explanation:

  • Selector fix: Using siblings(".ew-lookup-list") targets the adjacent div that contains both the text area and lookup button, since the hidden input is a sibling of this div.
  • Disabling the button: prop("disabled", true) properly sets the button's disabled state, which not only prevents clicks but also applies browser-native disabled styling.
  • Disabling the text area: Since the visible text is a <div> (not an input), we add a disabled class and adjust CSS to make it look disabled and prevent any user interaction (pointer-events: none stops clicks, opacity grays it out).

If your project already has a predefined disabled class (like ew-disabled which is common in some frameworks), you can use that instead of inline CSS for consistency.

内容的提问来源于stack exchange,提问作者Wilson Teo

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 09:14:39