gpt4 book ai didi

html - 如果登录为真,如何隐藏另一个 html 按钮?

转载 作者:行者123 更新时间:2023-11-28 17:17:34 25 4
gpt4 key购买 nike

这里有两个按钮选项卡:如何表达

1:

<% if logged_in? %>然后隐藏 b 按钮标签

2:

<% if studentlogged_in? %>然后隐藏A按钮标签

两种方法 <% if logged_in? %> , <% if studentlogged_in? %>有效

 <% if logged_in? %>  <<==#A button tab
<li><%= link_to "Users", users_path %></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Account <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><%= link_to "Profile", current_user %></li>
<li><%= link_to "Settings", edit_user_path(current_user) %></li>
<li class="divider"></li>
<li>
<%= link_to "Log out", logout_path, method: "delete" %>
</li>
</ul>
</li>
<% else %>
<li><%= link_to "Tutor Center", login_path %></li>
<% end %>



<% if studentlogged_in? %> <<==#B button tab
<li><%= link_to "StudentUsers", student_users_path %></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Account <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><%= link_to "Profile", studentcurrent_user %></li>
<li>
<%= link_to "Settings", edit_user_path(studentcurrent_user) %>
</li>
<li class="divider"></li>
<li>
<%= link_to "Log out", studentlogout_path, method: "delete" %>
</li>
</ul>
</li>
<% else %>
<li><%= link_to "Student Center", studentlogin_path %></li>
<% end %>

最佳答案

也许你的意思是这个结构:

<% if studentlogged_in? %>
...
<% elsif logged_in? %>
...
<% end %>

哪里显示学生版、普通版或什么都不显示,但绝不会同时显示两者。

关于html - 如果登录为真,如何隐藏另一个 html 按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43334869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com