嗨我有一個HTML表單,我有一些JavaScript,每次你重點放在輸入欄rel值消失,但它是在所有的輸入類型工作,除了電話,我不知道我做錯了什麼。HTML窗體 - 電話相對值不會消失在焦點
的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'));
}
});
的電話表單字段的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或蘋果瀏覽器。
感謝@brandonjordan工作(: –
很高興幫助快樂編碼! – internetgho5t