我有这样 如何选择表单元素和使用jQuery
<h:form id="validationFrom" >
<div id="mandotary" >
<h:panelGrid columns="4"
border="1"
width="50%"
style=""
columnClasses="asteriskColumns, nameColumns" >
<h:outputLabel value="*" style="color: red;" />
<h:outputLabel value="Heading: " />
<h:inputText id="heading" value="#{validation.heading}" />
<h:message id="headingMessage" for="heading" style="color: red" />
<h:outputLabel value="*" />
<h:outputLabel value="Select Category Type :" />
<h:selectOneRadio id="selectCategoryRadioButton"
rendered=""
value="#{validation.selectedRadioButton}"
layout="layoutDirection">
<f:selectItems value="#{validation.radioButtonItems}"/>
</h:selectOneRadio>
<h:panelGroup />
<h:outputLabel value="*"
rendered=""/>
<h:outputLabel value="Broad Category :"
rendered=""/>
<h:selectOneMenu id="broadCategory"
rendered=""
value="#{validation.selectedBroadCategory}" >
<f:selectItems value="#{validation.broadCategoryItemsList}"/>
</h:selectOneMenu>
<h:message id="broadCategoryMessage" for="broadCategory" style="color: red" />
<h:outputLabel value="*" />
<h:outputLabel value="Sub Category :" />
<h:selectOneMenu id="subCategory"
value="#{validation.selectedSubCategory}"
style="width: 250px;">
<f:selectItem itemLabel="---Select---" noSelectionOption="true" />
<f:selectItems value="#{validation.subCategoryItemsMap}"/>
</h:selectOneMenu>
<h:message id="subCategoryMessage" for="subCategory" style="color: red" />
<h:outputLabel value="*" style="color: red;" />
<h:outputLabel value="Description: " />
<h:inputText id="description" value="#{validation.description}" />
<h:message id="descriptionMessage" for="description" style="color: red" />
</h:panelGrid>
</div>
<h:commandButton id="saveButton"
value="Save"
action ="null"/>
<h:commandButton id="cancelButton"
value="Cancel"
action="null" />
</h:form>
</h:body>
现在我要选择带班mandoroty形式和DIV在JSF2.0一种形式,其JSF2.0孩子,这样我就可以检查div中的所有元素。我正在尝试此操作,但它不起作用
(function($){
var mandotoryFieldsArray = $("#validationFrom div.mandotary")
var test;
})(jQuery); //end of (function($){}
该行给出了空数组。为什么?我在选择表单元素时做错了什么?
可能重复[如何使用jQuery选择PrimeFaces UI或JSF组件?](http://stackoverflow.com/questions/7927716/how -to-select-primefaces-ui-or-jsf-components-using-jquery) – BalusC 2012-02-07 14:01:45
不,不是重复的。我的id不能正常工作,正如你在你的文章中所建议的:(我认为它是包含问题的脚本。 ..我在** Hemant Metalia **答案中添加了评论。你可以看到那里。谢谢 – Basit 2012-02-08 05:38:59