filterJobs: function()
{
var team = $('#selectOne').val();
var specialty = $('#selectTwo').val();
var level = $('#selectThree').val();
//var defSelectTeam=
$('.jobs').hide()
.filter('[data-team="' + team + '"][data-specialization="' + specialty + '"][data-level="' + level + '"]')
.show();
var newNumJobs = $('.jobs:visible').length;
$('table:visible:odd').css({'background-color': ' #F1F1F1'});
$('table:visible:even').css({'background-color': '#FFFFFF'});
if (newNumJobs <= this.pageSize)
{
$("#dvJobs span").text("Showing " + newNumJobs + " of " + newNumJobs + " jobs");
}
else
{
$("#dvJobs span").text("Showing " + this.pageSize + " of " + newNumJobs + " jobs");
}
this.buildPaginator(newNumJobs);
},
大家好,任何线索如何修改此过滤功能以进行选择过滤现在它可以工作,我需要设置一个默认值,在更改过滤之前显示所有选项?我只需要指出正确的大方向,我对 js 很垃圾,但正在努力改进。在此先感谢,html是这个//////,它通过从表格中删除数据属性来工作,该部分工作正常,只需要设置一个默认值,我正在考虑设置几个数据属性,但这似乎很乱。或设置一个检查值的 if 块,如果它的“选择一个”显示全部。抱歉扯淡了。
<select id="selectOne">
<option value="Select One">Select One </option>
<option value="Engineering">Engineering </option>
<option value="SoftwareDevelopment" >Software Development</option>
<option value="HumanResources" >Human Resources</option>
<option value="MarkettingAndSales">Marketting and Sales</option>
<option value="Administrative">Administrative</option>
<option value="Others">Others</option>
</select>
<label>Specialty:</label>
<select id="selectTwo">
<option class="Select One" >Select One </option>
<option class="MarkettingAndSales" value="Sales">Sales </option>
<option class="HumanResources" value="Recruitment">Recruitment </option>
<option class="Administrative" value="OfficeGeneral">Office General </option>
<option class="Engineering SoftwareDevelopment" value="WebDevelopment">Web Development </option>
<option class="SoftwareDevelopment" value="ApplicationDevelopment">Application Development </option>
<option class="SoftwareDevelopment" value="UIUXDesign">UI/UX Design</option>
<option class="Others" value="ScientificResearch">Scientific Research</option>
<option class="Engineering Others" value="ComputerHardwareNetworking">Computer Hardware Networking</option>
<option class="Others" value="Others">Others</option>
</select>
<label>Level:</label>
<select id="selectThree">
<option>Senior</option>
<option>Intermediate</option>
<option>Junior</option>
</select>
提前致谢。更新:我对其进行了一些修改以显示分页,但我想我在 if/else 块中使用了错误的 val 函数?
filterJobs: function()
{
var team = $('#selectOne').val();
var specialty = $('#selectTwo').val();
var level = $('#selectThree').val();
var newNumJobs = $('.jobs:visible').length;
if (team === 'SelectOne' && specialty === 'SelectOne')
{
$('.jobs').show();
}
else
{
$('.jobs').hide()
.filter('[data-team="' + team + '"][data-specialization="' + specialty + '"][data-level="' + level + '"]')
.show();
$('table:visible:odd').css({'background-color': ' #F1F1F1'});
$('table:visible:even').css({'background-color': '#FFFFFF'});
}
if (newNumJobs <= this.pageSize)
{
$("#dvJobs span").text("Showing " + newNumJobs + " of " + newNumJobs + " jobs");
}
else
{
$("#dvJobs span").text("Showing " + this.pageSize + " of " + newNumJobs + " jobs");
}
this.buildPaginator(newNumJobs);
}
为了澄清起见,我添加了被过滤的标签,希望有助于理解我的问题。
<table data-team="<?php print $name['team']; ?>" data-specialization="<?php print $name['speciality']; ?>" data-level="<?php print $name['level']; ?>" cellpadding="0" cellspacing="0" border="0" width="670px" class="jobs"><tr><td>
<tr><td colspan="4"><strong>Research Assistant</strong></td>
<td></td><td></td><td></td></tr>
<tr>
<td width="100">Location : </td>
<td colspan="3">Madrid</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td> Job Code : </td>
<td width="460">6767676</td>
<td></td>
<td></td>
</tr>
</table>