gpt4 book ai didi

jquery - 我如何在 jquery 中表示 document.getElementById ('page1:form2:amount' )?

转载 作者:行者123 更新时间:2023-12-01 07:32:33 24 4
gpt4 key购买 nike

我如何代表

document.getElementById('page1:form2:amount')

在 jQuery 中

我知道我可以使用

$('#amount')

访问id金额。ID 金额为 <apex:inputText/> type 这是输入文本在 Visualforce 页面中的表示方式。要访问此 id,我需要使用页面->表单->id 的层次结构。

谢谢

普拉迪

更新:Visualforce 页面中使用的代码。

<apex:page controller="acontroller" id="page1">
<apex:form id="form2">
<apex:inputText value="{!amt}" id="amount" onchange="calenddate();"/>
</apex:form>
</apex:page>

最佳答案

我知道现在有点晚了,但另一种方法是使用 jQuery 属性以选择器结尾 (http://api.jquery.com/attribute-ends-with-selector/)。

您知道您放入 apex 代码中的 id 始终是生成的 id 上的最后一个。所以你可以执行 jQuery('[id$="amount"]')

它的作用是选择 id 属性中以 amount 结尾的部分(您需要确定没有其他字段以这种方式结尾)。

这在过去对我来说非常有效。

关于jquery - 我如何在 jquery 中表示 document.getElementById ('page1:form2:amount' )?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4966445/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com