我試圖使用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