Remove CSS “top” and “left” attributes with jQuery

后端 未结 13 1248
故里飘歌
故里飘歌 2020-12-02 07:07

Im building a draggable map that when the map is dragged the element is given a \'left\' and \'top\' attribute with values for each as so...

13条回答
  •  情深已故
    2020-12-02 07:52

    $.fn.removeCss=function(prop){
       if(!prop){
              return $(this).removeAttr('style').removeAttr('class');
         }
        else{
             return $(this).css(prop,null);
        }
    
    }
    

    then if you want to remove css prop(s) :

        $('#mydiv').removeCss('color');
    //To remove all prop Css
        $('#mydiv').removeCss();
    

提交回复
热议问题