这来自BootStrap 3的网站:
User input
Use the <kbd> to indicate input that is typically entered via keyboard.
To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
To edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>
如何将它们合并到占位符中(输入字段中的背景文本)?
$j('#text_input').attr('placeholder','Enter options and hit <kbd>Enter</kbd> key');
上述代码不会更改文本样式。它将其视为字面上< kbd>Enter< /kbd>
发布于 2014-10-07 14:27:17
下面是一个示例,说明如何使用HTML而不是使用placeholder
属性来完成任务。但这似乎比它的价值更多的工作。
jsFiddle演示
HTML
<div class="input-wrap">
<input class="form-control" type="text" />
<span class="placeholder">Enter options and hit <kbd>Enter</kbd> key</span>
</div>
CSS
.input-wrap { position: relative; }
.placeholder {
position: absolute;
top: 7px;
left: 6px;
}
jQuery
$('.placeholder').click(function(){
$(this).prev().focus();
});
$('.form-control').focus(function() {
$(this).next().hide();
});
$('.form-control').blur(function() {
if($(this).val() == "")
$(this).next().show();
});
https://stackoverflow.com/questions/26234731
复制相似问题