यदि पृष्ठभूमि को फीका करने के लिए शुद्ध जेक्यू का उपयोग प्लगइन के बिना काम नहीं करता है, तो CSS3 के साथ ऐसा करने के लिए एक चालाक (हालांकि प्रगतिशील रूप से बढ़ाया नहीं गया) तरीका है।
यह फ़ंक्शन सीएसएस के माध्यम से किसी दिए गए तत्व को "संक्रमण" विशेषता लागू करेगा, इसके बाद तत्व को पृष्ठभूमि रंग दिया जाता है जो सीएसएस में फीका होता है।
यदि आप इसे एक लहर की तरह होना चाहते हैं ("यहां देखो!"), आधे सेकेंड की देरी के बाद, तत्व को वापस सफेद पर बदलने के लिए कतारबद्ध किया जाता है।
अनिवार्य रूप से जेक्यू तत्व को केवल एक रंग पर तत्व को ब्लिंक करता है, फिर सफेद पर वापस जाता है। CSS3 लुप्तप्राय का ख्याल रखता है।
//reusable function to make fading colored hints
function fadeHint(divId,color) {
switch(color) {
case "green":
color = "#17A255";
break;
case "blue":
color = "#1DA4ED";
break;
default: //if "grey" or some misspelled name (error safe).
color = "#ACACAC";
break;
}
//(This example comes from a project which used three main site colors:
//Green, Blue, and Grey)
$(divId).css("-webkit-transition","all 0.6s ease")
.css("backgroundColor","white")
.css("-moz-transition","all 0.6s ease")
.css("-o-transition","all 0.6s ease")
.css("-ms-transition","all 0.6s ease")
/* Avoiding having to use a jQ plugin. */
.css("backgroundColor",color).delay(200).queue(function() {
$(this).css("backgroundColor","white");
$(this).dequeue(); //Prevents box from holding color with no fadeOut on second click.
});
//three distinct colors of green, grey, and blue will be set here.
}
स्रोत
2012-02-17 19:14:26
यह बहुत अच्छा काम करता है, आपकी मदद के लिए धन्यवाद! –
यह लिंक अब मान्य नहीं है - http://plugins.jquery.com/project/color –