使用JQuery从子CSS类中删除转换

时间:2014-11-23 08:00:28

标签: javascript jquery css css3

我有一个有子类的ID。我希望ID转换,但是类不要转换。因为类在id内,所以它正在转换。我查看了CSS jquery文档,从中我已经找到了如何转换这两个元素,但不能单独转换父元素。

这是CSS

#outside {
    background-size: 25em, 25em, auto, cover;
    color: white;
    cursor: default;
    padding: 6em 0;
    text-align: center;
}



    #outside .inside {
        background: rgba(52, 27, 43, 0.5);
        color: white;
        display: inline-block;
        opacity: 0;
        padding: 3em;
        text-align: center;
    }

这是我试图让jquery工作的尝试

<script>
        $(document).ready(function() {
        var timeToDisplay = 4000;
        var outside = $('#outside');
        var urls = [
            'images/image1.jpg',
            'images/image2.jpg',
            'images/image3.jpg'
            ];

        var index = 0;
        var transition = function() {
            var url = urls[index];

            outside.css('background-image', 'url("images/light-bl.svg"), url("images/light-br.svg"), url(' + url + ')');

            index = index + 1;
            if (index > urls.length - 1) {
                index = 0;
            }
        };

        var run = function() {
            transition();
            outside.fadeIn('slow', function() {
                setTimeout(function() {
                    outside.fadeOut('slow', run);
                }, timeToDisplay);
            });
        }

        $("div.inside").css("-webkit-transition","none !important;");
        $("div.inside").css("-moz-transition","none !important;");
        $("div.inside").css("-ms-transition","none !important;");
        $("div.inside").css("transition","none !important;");



        run();
});
</script>

1 个答案:

答案 0 :(得分:1)

var outside = $('#outside:not(.inside)');怎么样?