允许用户选择并复制引导按钮标签 [英] Allow the user to select and copy bootstrap button label

查看:145
本文介绍了允许用户选择并复制引导按钮标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要让用户选择并复制 bootstrap 按钮标签。它应该喜欢一个标签。根据此问题无法在引导对话框页脚中使用标签。如何做到这一点?

Want to let user to select and copy bootstrap button label. It should like a label. According to this question unable to use labels in Bootstrap dialog footer. How to do it?

 <button type="button" class="btn btn-default">sample@yahoo.com</button>


推荐答案

从用户体验的角度来看,我不明白为什么你会想这样做。我的意思是,一个按钮用于呼吁行动。复制文本时,行动号召是否会发生?我认为你最好使用文本元素或段落来复制文本。

From a UX perspective, I don't get why you would want to do that. I mean, a button is used for a call to action. When copying text, should the call to action happen or not? I think you better use a text element or paragraph for copying text.

然而,有多种方法可以在按钮中选择文本。下面是我通过将文本字段放入按钮所做的一个简单示例。

There are however multiple ways to make text selectable in a button. Here is a quick example I made by putting a text field into the button.

https://jsfiddle.net/o8eze0d2/

您可以通过添加按钮onclick来选择文本时禁用按钮操作

You can disable the button action when selecting text by adding in the onclick of the button

if (event.target === this)

,或者通过在文本字段添加一个onmousedown侦听器调用来完成一个

or by adding an onmousedown listener call on the text field that does a

event.stopPropagation();

这篇关于允许用户选择并复制引导按钮标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆