javascript 使用 jquery 更改 h:outputtext 的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5712329/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
change value of h:outputtext using jquery
提问by Annu
i have one component OutputText , i want to change its value using jquery,
我有一个组件 OutputText ,我想使用 jquery 更改它的值,
my component is,
我的组件是,
<h:outputText id="txt_pay_days" value="0"
binding="#{Attendance_Calculation.txt_pay_days}"/>
thanks for any help...
谢谢你的帮助...
回答by Jigar Joshi
<h:outputText>
will be converted to <span>
in raw HTML So,
<h:outputText>
将转换为<span>
原始 HTML 所以,
Use id of the DOM and play with jQuery
使用 DOM 的 id 并使用 jQuery
${"#txt_pay_days"}.text("New Value To Set");
回答by BalusC
The <h:outputText>
renders a HTML <span>
with the value as its body.
在<h:outputText>
渲染HTML<span>
与价值作为其身。
<span id="txt_pay_days">0</span>
The jQuery .val()
functionworks on HTML inputelements like <input type="text">
only. The <span>
isn't an input element at all. Instead, you need to use the jQuery .text()
function.
在jQuery的.val()
功能HTML的作品输入元素喜欢<input type="text">
而已。的<span>
是不是在所有输入元件。相反,您需要使用jQuery.text()
函数。
$("#txt_pay_days").text("123");
回答by Vivek
try this..
试试这个..
$('#txt_pay_days').val('valueYouWantToInsert');