在我的 HTML 中,我有一个位于 div 中的按钮:
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
The Close当用户复制文本时双击 my url 输出分区可以在这里看到:
<div class="modal-body">
<div id="url-output"></div>
</div>
下面是相关的Javascript。完整JS可以查看here http://pastebin.com/L4n5q2Te.
$('#url-output').text("http://url.domain.me/" + data.shortID);
所以本质上,如果url 输出文本类似于“www.google.com”,复制的文本将显示为:
www.google.com
Close
我尝试了几种解决方案,例如禁用指针事件,以及建议here https://stackoverflow.com/questions/826782/how-to-disable-text-selection-highlighting-using-css。但我没有运气。
我怎样才能排除Close我的输出中的文本?
您可以使用伪元素添加按钮文本:before
or :after
禁用选择。
.my-button:before {
content: "Close";
}
Example <button class="my-button"></button>
如果您需要它具有更好的可访问性,请使用.sr-only
Bootstrap 内置的类。如果按钮后没有任何文本,则此方法有效。
.my-button:before {
content: "Close";
}
/* http://getbootstrap.com/css/#helper-classes-screen-readers */
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
Example <button class="my-button"><span class="sr-only">Close</span></button>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)