我试图使用JavaScript来访问JSF的outputText价值的价值,但它抛出undefined.Below调用的访问JSF的outputText(标签)元素是代码JavaScript是无法通过inspite ID
<ui:composition template="/template.xhtml">
<ui:define name="head">
<script type="text/javascript">
function sendDetails()
{
alert("am inside js");
var key=document.getElementById('editForm:key').value;
alert(key);
}
</script>
</ui:define>
<ui:define name="body">
<f:view>
<h:form id="editForm">
<h:outputLabel id="key" value="#{editController.details.clientId}" style="font-weight: bold" >
<h:commandLink id="analytics" onclick="sendDetails()" value="View"></h:commandLink>
</h:form>
</f:view>
</ui:define>
</ui:composition>
当我点击命令链接它抛出undefined!我不能够访问的输出值label.I检查的萤火查看页面源
<label id="editForm:key" style="font-weight: bold">
1e20bb95-753e-4252-b6d6-e109fa07171e
这似乎与right..I检查console.log(document.getElementById('editForm:key'))
console.log(document.getElementById('editForm:key').value)
这表明<label id="editForm:key"> undefined
如何访问标签/ JSF的outputText value.I需要在JavaScript的解决方案只
无法得到它与innerHTML的或outertext工作,但用的textContent工作完美...谢谢多个属性:) – enthusiastic 2012-02-16 11:38:05