嗨,我有一个 html 表单,我有一些 javascript,每次您关注输入字段时,rel 值都会消失,但是它适用于除电话以外的所有输入类型,我不确定我做错了什么。
javascript是:
$(document).ready(function() {
$('select.fancyselect').fancySelect();
$('input[type=text], input[type=email], input[type=phone], input[type=url], textarea,').focus(function(){
if($(this).val() == $(this).attr('rel')) {
$(this).val('');
}
});
$('input[type=text], input[type=email], input[type=phone], input[type=url], textarea').blur(function(){
if($(this).val() == '') {
$(this).val($(this).attr('rel'));
}
});
tel 表单字段的 html 是:
<div class="control-group">
<label class="control-label" for="field-phone">Phone Number:<br /> <em>(Optional)</em></label>
<div class="controls">
<input type="number" name="field-phone" id="field-phone" value="<?= $_POST['field-phone']; ?>" rel="Phone number here...">
</div>
</div>
我也在使用引导程序,我发现这个问题只发生在 Firefox 中,而不是 chrome 或 safari。