English 中文(简体)
Jquery .css () hack to make it listed to animate?
原标题:Jquery .css() hack to make it appear to animate?

我可以不使用 j或UI。 我有一个包含无法执行的内容的亲子。 因此,我无法做简单的不透明做法。

    <img class="badge_ico" rel="28" src="" />
    <div>I <3 Ford</div>
</div>  

是否有象<条形状>(<>环形>>)的黑体,或者类似东西,能够把颜色从黑暗灰色到中灰色之间 appear起来吗? 如果我使用RBG值(0,0,0)的话,可以做一些事情。

内容的颜色是我想在 h上加固的东西。

最佳回答

在此,我认为这是自动化做法。 可以通过下列途径更好地优化: 警告说,它有些是弱肉体(我有一份社会研究文件,现在撰写:P)。

Demo

HTML

<div id="box">This is a test</div>

CSS

#box
{
    color:white;
    background:#333;
    padding:20px;
    margin:20px;
    float:left;
    cursor:pointer;
}

javascript

var box = document.getElementById("box");

box.onclick = function(){
    box.style.background = "#333";
    var current = Math.round(0.2 * 256);
    var step = 1;
    var ms = 10;
    var animation = setInterval(function(){
        current += step;
        var shade = (current).toString(16);
        box.style.backgroundColor = "#" + shade + shade + shade;
        if(parseInt(shade,16) > 0.7 * 256)
            clearInterval(animation);
    },ms);
}
问题回答

您可以设立一系列彩色,并使用<代码>Interval(),在间隔期更改颜色:

var target_el = $( #target_element ),
    colors    = [ #999 ,  #666 ,  #333 ,  #ccc ],
    index     = 0,
    timer;

target_element.on( mouseenter , function () {
    timer = setInterval(function () {
        if (index in colors) {
            target_el.css({
                 background-color  : colors[index]
            });
            index++;
        } else {
            index = 0;
            clearInterval(timer);
        }
    }, 100);
});

http://jsfiddle.net/jasper/ZXCjL/2/“rel=“nofollow” http://jsfiddle.net/jasper/ZXCjL/2/。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签