我想刪除表中文本字段的禁用屬性,當用戶從所選行中單擊編輯按鈕,但我不知道如何過濾文本字段我想改變。更改行jquery中元素的屬性
這裏是我的PHP:
$query_select = "SELECT `users_id`,`users_studno`,`users_fname`,`users_lname`,`users_email`,`users_password` FROM `tbl_usersinfo` LIMIT 20";
if($run_query = mysqli_query($con,$query_select))
{
while($row = mysqli_fetch_assoc($run_query))
{
$id_val = htmlentities($row['users_id']);
$studno_val = htmlentities($row['users_studno']);
$fname_val = htmlentities($row['users_fname']);
$lname_val = htmlentities($row['users_lname']);
$email_val = htmlentities($row['users_email']);
$password_val = htmlentities($row['users_password']);
echo "<tr class = 'special_rows'>";
echo "<td>"."<input type = 'checkbox' value = 'id_val' style = 'cursor:pointer; '>"."</td>";
echo "<td>".$id_val."</td>";
echo "<td>"."<input type = 'text' value = '$studno_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<input type = 'text' value = '$fname_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<input type = 'text' value = '$lname_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<input type = 'text' value = '$email_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<input type = 'text' value = '$password_val' class = 'data_field' disabled>"."</td>";
echo "<td>"."<a style = 'cursor:pointer' class = 'edit'>edit</a> <a style = 'cursor:pointer' class = 'save'>delete</a>"."</td>";
echo "</tr>";
}
}
這裏是我的jQuery:
var edit = 0;
var save = false;
$('.edit').click(function()
{
if(edit %2 == 0)
{
$('#tbl_users').find('tr').click(function(){
alert('You clicked row '+ ($(this).index()));
$(this).index().$('.data_field').removeAttr('disabled');
});
$(this).text('save');
}
else
{
$(this).text('edit');
}
edit++;
});
例如: 我從第一行單擊編輯按鈕,所有的第一行文本框應該刪除所有的禁用的屬性。
爲什麼在HTML輸出中屬性和它們各自的屬性值之間有空格? – Svenskunganka 2014-09-28 11:31:27
我無法理解你的問題。 – 2014-09-28 11:42:59
這個''應該是''。這是很好的做法。 – Svenskunganka 2014-09-28 11:44:26