开发者

About changing attributes of draggable elements

开发者 https://www.devze.com 2023-04-10 21:39 出处:网络
I want to change the attributes of a draggable element during dragging (font color, background color, z-index).I don\'t know if the problem is IE9, but there are attributes for which the code works, t

I want to change the attributes of a draggable element during dragging (font color, background color, z-index). I don't know if the problem is IE9, but there are attributes for which the code works, there are others for which it doesn't.

$(function() {
    $('.comurl').draggable({ 
        start: function(event, ui) { 
            $(this).css("background-color","red"); //works
            $(this).css("color","red");  开发者_运维问答          //doesn't
            $(this).css("z-index","999999");       //doesn't
            },
        stop: function(event, ui) {  
            $(this).css("background-color","green"); //works
            $(this).css("color","green");            //doesn't
            $(this).css("z-index","auto");           //doesn't
        } 
    });
});

Are the names for the properties different when called in that way? Is this a problem with IE9?


why not use a class instead?

$(function() {
    $('.comurl').draggable({ 
        start: function(event, ui) { 
            $(this).addClass('dragging');
            },
        stop: function(event, ui) {  
            $(this).removeClass('dragging');
        } 
    });
});

note: there's a default class (ui-draggable-dragging) that you could use in your css without having to write any additional js as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消