2009-09-08 27 views

回答

2

您可以製作像這樣的功能。由於您沒有指定應該如何閃爍或多少次,因此我將背景顏色更改爲紅色,然後在500毫秒後將其更改回前一個。這將使它看起來像閃爍。

function blink($target) { 
    // Set the color the field should blink in 
    var backgroundColor = 'red'; 
    var existingBgColor; 

    // Load the current background color 
    existingBgColor = $target.css('background-color'); 

    // Set the new background color 
    $target.css('background-color', backgroundColor); 

    // Set it back to old color after 500 ms 
    setTimeout(function() { $target.css('background-color', existingBgColor); }, 500); 
    } 

當你要撥打的閃爍功能只是這樣做:

function processForm() { 
    blink($("#name")); 
} 

如果你有一個輸入域ID 'name'


眨眼select元素這將工作

HTML:

<select id="selectList"> 
    <option>Hello</option> 
    <option>World</option> 
    </select> 

的JavaScript(例如在準備):

$(function() { 
    blink($("#selectList")) 
}); 
+0

如何使它適用於