javascript - 如果在页面加载禁用按钮
问题描述
使用 Mysql PHP,在一个页面上有一个学生列表,每行都有学生 ID、姓名、生日和几个按钮。如果另一个名为“saral_tcissue”的表中存在student_id,我想禁用以下按钮。如果在 saral_tcissue 中找不到 student_id,用户将能够单击按钮并填写模态表单。学生列表来自具有 student_id 和其他列的表 saral_2016。而 saral_tcissue 表也有 student_id 和其他列。
<td>
<a class="btn btn-sm btn-primary" type="button" name="nirgam" id="nirgam"
data-toggle="modal"
data-target="#exampleModal"
data-whatever="<?php echo $row['student_id']; ?>">
<i class="glyphicon glyphicon-pencil"></i>निर्गम
</a>
</td>
解决方案
也许是这样的:
$('.btn').each(function(){
var this_whatever=$(this).attr(data-whatever);
if(this_whatever=='saral_tcissue'){
this.disabled = true;
}
});
推荐阅读
- python - 如果满足条件,则使用另一列中的多个字符串之一更改一列
- android-fragments - 使用导航 UI 时使用 Espresso 正确测试片段
- foreach - MySQL 8 Recursive CTE 为每个项目创建行
- python - 删除二叉树最左边的叶子
- elixir - (FunctionClauseError) CheckersgameWeb.GamesChannel.handle_in/3 中没有函数子句匹配
- python-3.x - 临时变量的变化正在影响从中提供的变量
- c# - 如何在mongodb + C#中计算、选择和更新嵌套元素
- python - GitStats 无法识别 Gnuplot (Windows)
- c - 试图打印一个 int 数组的元素,但我得到了一些奇怪的结果
- kubernetes-helm - 多个 Helm chart 和 parent chart 需要先执行,并在所有子 chart 完成后完成