php - 如何禁用 <a href> 的功能

标签 php jquery mysql

我想禁用此功能:

<a href="javascript:void(0);" role="button" onclick="edit_user('<?php echo $data['user_id']; ?>')"><i class="glyphicon glyphicon-pencil"></i>

当 user_id = 1 时。有人可以帮助我吗?

最佳答案

您可以在 php 中检查 $user_id ==1 并回显您需要的代码

<a <?php echo ( $user_id ==1 ) ? '' : 'href="javascript:void(0);"' ?> 
      role="button" onclick="edit_user('<?php echo $data['user_id']; ?>')">
          <i class="glyphicon glyphicon-pencil"></i>
</a>

关于php - 如何禁用 <a href> 的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40516756/

相关文章:

javascript - 将 UL 与祖 parent UL 对齐

jquery - 未捕获的类型错误 : Object #<HTMLDivElement> has no method 'height' - Can't call jquery method on element

Javascript - 将 youtube/vimeo url 转换为嵌入版本以用于论坛评论功能

mysql - SQL读取网格矩阵

MySQL 截断 GROUP_CONCAT 函数的连接结果

php - 将 MySQL 输出写入变量时出现 "Array to string conversion"

php - 用于在一张表中显示和排序消息及其回复的 SQL

PHP AES 加密 - 无法解密数据库中存储的某些值

php - Angular 2 : Send data to MySQL with php file

php - 如何使用 Facebook 作为我的网站登录名?