我是 JavaScript 新手。我需要帮助来修改这个脚本。当我单击表格行时,我希望使用按钮的唯一 ID 调用下面的按钮。
$(document).ready(function(){
$(selector).click(); //selector = h:commandLink
});
$(selector).find('tr').each(function(){ //selector = h:dataTable
$(this).click(function(){
$(selector).trigger('click'); //selector = h:commandLink
});
});
<h:commandLink id="lnkHidden" action="#{bean.pageRedirect}" style="text-decoration:none; color:white; display:none">
</h:commandLink>
你能帮我解决这个问题吗?
PS这是表格的代码:
<h:form id="form" >
<!-- The sortable data table -->
<h:dataTable id="dataTable" headerClass="columnHeader" value="#{bean.dataList}" binding="#{table}" var="item">
<!-- Check box -->
<h:column>
<f:facet name="header">
<h:selectBooleanCheckbox style="margin-left: 0px;" value="#{bean.value}" class="checkall" >
<f:ajax listener="#{bean.value}" render="@form" />
</h:selectBooleanCheckbox>
</f:facet>
<h:selectBooleanCheckbox onclick="highlight(this);" value="#{bean.value" >
<!-- if the user deselects one row deselect the main checkbox -->
<f:ajax listener="#{bean.deselectMain}" render="@form" />
</h:selectBooleanCheckbox>
<!-- Click on table code -->
<h:commandLink id="lnkHidden" action="#{bean.pageRedirect}" style="text-decoration:none; color:white; display:none">
</h:commandLink>
</h:column>
<!-- Row number -->
<h:column>
<f:facet name="header">
<h:outputText value="№" />
</f:facet>
<h:outputText value="#{bean.value}" />
</h:column>
..........
</h:dataTable>
这是生成到 Web 浏览器中的代码的一部分:
<tr class="">
<td>
<input id="form:dataTable:1:j_idt17" type="checkbox" onclick="jsf.util.chain(this,event,'highlight(this);','mojarra.ab(this,event,\'valueChange\',0,\'@form\')')" name="form:dataTable:1:j_idt17">
<a id="form:dataTable:1:lnkHidden" onclick="mojarra.jsfcljs(document.getElementById('form'),{'form:dataTable:1:lnkHidden':'form:dataTable:1:lnkHidden'},'');return false" style="text-decoration:none; color:white; display:none" href="#"></a>
</td>
<td>2</td>
<td>35435</td>