即時嘗試隱藏包含文本的所有行使用jquery從下拉列表中獲取,但我只是不能讓它工作。 這是功能:隱藏在表中的所有行,除了包含數據從rdropdown
$(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>
任何想法,爲什麼沒有它的工作嗎?
UPDATE
這是我如何創建表:
<table class="table table-bordered table-hover" ng-controller="tableCtrl" ng-controller="Ctrl">
<thead>
<th>user name</th>
<th>script name</th>
<th>cron format</th>
</thead>
<tbody ng-repeat="(user_id, row) in data | filter:search">
<tr ng-repeat="(script_id, cron_format) in row ">
<td class="userName">{{user(user_id)}}</td>
<td class="scriptName">{{script(script_id)}}</td>
<td class="cronFormat"><span contenteditable="true" ng-repeat="l in letters(cron_format) track by $index">{{l}}</span><button class="save" ng-click="saveCron(user_id,script_id,cron_format)">save</button></td>
</tr>
</tbody>
</table>
,其結果是有三列和下拉包括所有USER_NAME
您可以張貼表HTML和要發生什麼的例子嗎? – Wilmer 2015-02-11 19:59:02
是肯定一秒 – user3194267 2015-02-11 20:25:24
好吧,你想隱藏包含所選用戶名的行是嗎? – Wilmer 2015-02-11 20:40:27