button 相关问题

按钮是图形用户界面中的简单元素,可以将鼠标点击或手指点击(在移动设备上)作为输入。

名称旁边按钮中的图标(p 标签)

我把按钮放在一个 div 中,按钮应该有图标,图标旁边有名称,但是在编写代码后,名称一直显示在图标之前。 我试过使用 CSS 并更改...

回答 0 投票 0

为什么我在 python arcade 部分的按钮似乎不活动?

你好,这是我在 stackoverflow 上的第一篇文章,所以如果我的文章不相关或有问题,我提前道歉。 我正在使用 python 库 Arcade 和 Arcade.gui。 目前我尝试添加 GUI widg ...

回答 0 投票 0

高架按钮和轮廓按钮之间的动画

我想要一个在 ElevatedButton 和 OutlinedButton 之间切换的按钮。我剪掉了这段代码: 类主页扩展 StatefulWidget { const Home({super.key}); @覆盖 状态 创建...

回答 1 投票 0

如何让我的主要代码在 pysimplegui 应用程序中工作

我对 python 和 GUI 应用程序很陌生,所以我经常感到很困惑。我为假健身房会员应用程序创建了一个 pysimplegui 应用程序,需要某些组件。这...

回答 0 投票 0

在 C# 中使用“帮助”按钮

我正在尝试使用 C# 中的帮助按钮,但我不知道如何制作它,所以如果我按下它,将出现一个消息框。我说的是这个按钮

回答 0 投票 0

在 RPPreviewViewController (ReplayKit) 中自定义按钮的颜色

我用 RPScreenRecorder 录制了一个视频序列。一切正常。 现在我想自定义预览控制器的 UI。 我怎样才能改变取消和保存的颜色

回答 2 投票 0

单击按钮时更改字体真棒图标

我正在使用此代码播放/暂停背景音频。 我正在使用此代码播放/暂停背景音频。 <div class="music-box"> <audio id="losAudio" src="images/honcayeu.mp3"></audio> <button id="btn_playPause"> <i class="fa fa-music"></i> </button> </div> var losAudio = document.getElementById("losAudio"); function losAudio_playPause() { var isPaused = losAudio.paused; losAudio[isPaused ? "play" : "pause"](); } document.getElementById("btn_playPause").addEventListener("click", losAudio_playPause); 但现在我想要点击按钮时,图标将更改为 fa-pause 图标。 可以告诉我一个简单的解决方案吗?谢谢 要在播放音频时将按钮图标从 fa-music 更改为 fa-pause,您可以修改 losAudio_playPause 函数以相应地更新按钮图标。 试试这个: var losAudio = document.getElementById("losAudio"); var playPauseButton = document.getElementById("btn_playPause"); function losAudio_playPause() { var isPaused = losAudio.paused; losAudio[isPaused ? "play" : "pause"](); playPauseButton.innerHTML = '<i class="fa ' + (isPaused ? 'fa-music' : 'fa-pause') + '"></i>'; } playPauseButton.addEventListener("click", losAudio_playPause); 它的作用是检查音频当前是暂停还是正在播放,并使用三元运算符分别将按钮图标设置为 fa-music 或 fa-pause。然后使用 innerHTML 属性用新图标更新按钮的内容。 你需要在你的函数中做一个动作。尝试获取元素(添加ID)并更改第i个元素的类 您可以使用classList、add()和remove(): let pause = true; document.getElementById("btn_playPause").addEventListener("click", () => { let icon = document.querySelector("i"); if (pause) { icon.classList.add("fa-pause"); icon.classList.remove("fa-music"); pause = false; } else { icon.classList.add("fa-music"); icon.classList.remove("fa-pause"); pause = true; } }); 第二种方式是你可以使用className: document.querySelector("i").className = `fa ${pause ? "fa-pause" : "fa-music"}`; // Get references to the DOM elements we need const losAudio = document.getElementById("losAudio"); const playPauseButton = document.getElementById("btn_playPause"); const playIcon = playPauseButton.querySelector("i.fa-music"); // Create the pause icon element and add the appropriate CSS classes const pauseIcon = document.createElement("i"); pauseIcon.classList.add("fa", "fa-pause"); // Define a function to update the play/pause icon based on the current state of the audio player const updatePlayPauseIcon = () => { // If the audio is paused, remove the pause icon and restore the play icon if (losAudio.paused) { playIcon.classList.remove("fa-pause"); playPauseButton.removeChild(pauseIcon); } // Otherwise, add the pause icon to the button else { playIcon.classList.add("fa-pause"); playPauseButton.appendChild(pauseIcon); } }; // Define a function to toggle the audio player between play and pause const togglePlayPause = () => { // Call the play() or pause() method on the audio player depending on its current state, // and then update the play/pause icon losAudio[losAudio.paused ? "play" : "pause"](); updatePlayPauseIcon(); }; // Attach the togglePlayPause function to the click event of the play/pause button playPauseButton.addEventListener("click", togglePlayPause); <!-- HTML markup for the music player --> <div class="music-box"> <audio id="losAudio" src="images/honcayeu.mp3"></audio> <button id="btn_playPause"> <i class="fa fa-music"></i> </button> </div> 您可以通过更改按钮内图标元素的类来更新按钮的图标。这是您的代码的更新版本,它在播放音频时将图标更改为“fa-pause”,在暂停时将图标更改为“fa-music” updatePlayPauseIcon 函数检查音频是否暂停,并相应地通过添加或删除“fa-pause”类以及附加或删除暂停图标元素来更新按钮的图标。 losAudio_playPause 函数在播放或暂停音频后调用 updatePlayPauseIcon。

回答 4 投票 0

表格动作和方法[关闭]

为什么更新按钮不起作用的代码可能有什么问题?表单操作和方法不起作用。单击更新按钮后无法加载。对此没有回应。 <

回答 0 投票 0

我试着用一个按钮来取消禁止被禁止的用户,但是idk

我尝试执行一个带有按钮的禁止命令来取消禁止 discord.py 中被禁止的用户 我试过了 @client.hybrid_command() @commands.has_permissions(ban_members=True) async def ban(ctx, member:discord.Membe...

回答 1 投票 0

单击项目时它没有响应

单击 F1 团队时应显示团队统计数据。它适用于车手,但不适用于 F1 车队。当在“车手排名”中单击车手并显示他们的统计数据时,然后您...

回答 2 投票 0

从今天开始计算数据并将其显示在可通过按钮选择的表格上

我希望构建类似这样的东西: 一般条件是: 直到当月的第 10 天,应显示接下来的三个月。例如:今天的日期应该产生......

回答 2 投票 0

单击按钮以 html 格式运行 PHP 脚本

我想在 html 中单击按钮时运行 php 脚本。我在这里看了很多帖子,但它们似乎不起作用。截至目前,我正在尝试此处的解决方案,但它不起作用。我不知道

回答 2 投票 0

单击时如何让轮播指示器按钮响应?

我无法使用位于轮播下方的指示按钮滚动浏览图像。多次梳理代码后,我发现困难在于没有...

回答 0 投票 0

Blogger 按钮链接点击后更改

在博客中,如果用户点击按钮,它会重定向到所需的链接。如果用户第二次单击同一个按钮,我想让该按钮重定向到另一个链接。那我怎么才能...

回答 0 投票 0

在 Python 的 streamlit 中单击按钮两次时小部件消失 [重复]

我想要达到的目标 仅当在 streamlit 中单击按钮时才显示小部件。耗时操作的返回值将加载到小部件。在进行操作时,

回答 1 投票 0

向 GtkButton 添加工具提示

我想给 GtkButton 添加一个工具提示。 这似乎是一件容易的事,除了我不知道为什么不起作用。我拥有的: 1) GtkButton* 按钮 = gtk_button_new_with_label("按钮");

回答 3 投票 0

如何在 bootstrap 3 table 的搜索框旁边添加一个按钮

我需要在搜索框旁边添加一个按钮,因为搜索框来自 bootstrap 我不能在它旁边插入一个按钮 这是我的代码 我需要在搜索框旁边添加一个按钮,因为搜索框来自 bootstrap 我不能在它旁边插入一个按钮这是我的代码<table id="example" class="table table-striped table-bordered" style="width:100%"> <thead> <tr> <th>No</th> <th>Request Type</th> <th>Request ID</th> <th>Requester</th> <th>Traveler Employee</th> <th>Pending Approver</th> <th>Status</th> <th>Status Reason</th> <th>Stage</th> <th>Request Date</th> <th>Due Date</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Travel Request</td> <td>TR000001</td> <td>Matthew Man Young Leemans</td> <td>Matthew Man Young Leemans</td> <td>Matthew Man Young Leemans</td> <td>Initiate Request</td> <td>New</td> <td>Draft</td> <td>20-03-2023</td> <td>20-03-2023</td> </tr> </tbody> </table> </script> <script> $(document).ready(function () { $('#example').DataTable(); }); </script> 有什么帮助吗?谢谢你。

回答 0 投票 0

如何在 SwiftUI 中正确创建按钮。该代码有效,但它在重写它的下一行代码中抛出错误

/* 以下代码产生两个警告: 在“try”表达式中没有调用抛出函数 “catch”块无法访问,因为“do”块中没有抛出错误 */ 按钮("

回答 1 投票 0

无法成功将按钮添加到 ascx 用户控件

我正在尝试通过添加用户控件来更新现有的 ASP/MVC 网站。我最终想将此用户控件添加到几个母版页,因为它是一个“接受 cookie 横幅&

回答 0 投票 0

Javascript 按钮识别

我有一个生成 DOM 表的函数。在表格中我有多个按钮。如果我生成多个表,我怎么知道在哪个表中按下了其中一个按钮。对于这个例子,我...

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.