这是来自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');
上述代码不会更改文本样式。它把它视为字面上&lt; KBD&GT;输入&LT; / KBD&GT;
答案 0 :(得分:1)
以下是使用HTML标记而不是使用placeholder
属性的示例。但这似乎比它的价值更多。
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();
});