iam试图隐藏表中除<td>
之外的所有行,其中包含与从下拉列表中选择的用户相同的文本。认为它应该是容易的,但IM与它挣扎了很久了......我想是这样的:从下拉菜单中隐藏所有包含td值的行
$(document).ready(function() {
$('select[name=selectName]').change(function() {
$("td").each(function(index, paragraph) {
$td = $(paragraph);
if ($td.html() === $('select[name=selectName]').val()) {
//hide the matched row rather than remove it
$(not(this)).parent("tr:first").hide();
}
});
$('select[name="selectName"]').on('change', function() {
$("tr").show();
});
});
});
但它没有工作,所以我尝试这样做:
$(document).ready(function(){
$('select[name=selectedName]').change(function() {
$('tr').filter(function() {
return $(this).find('td').filter(function() {
return $(this).text().indexOf('$('select[name=select2]').val()') == -1;
}).length;
}).$(this).parent("tr:first").hide();
});
});
,但没有工作,以及...这是我如何建立我的下拉列表:
$query = "SELECT user_name FROM users";
$result = mysql_query($query); ?>
<select name="selectedName" id="userSelected">
<option value="" disabled selected>user name</option>
<?php while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?>
<option value="<?php echo $line['user_name'];?>">
<?php echo $line['user_name'];?>
</option>
<?php } ?>
</select>
任何帮助导致解决方案?谢谢
怎么样这个问题,从您的最后两个有什么不同? – j08691 2015-02-11 18:37:05
此问题没有需要回答的详细信息。 – 2015-02-11 18:37:18
你的桌子是什么样的? – bobdye 2015-02-11 18:54:50