最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Removing float:none from CSS class - Stack Overflow

programmeradmin2浏览0评论

Using Google Chrome Developer Tools I uncheck "float:none;" from the Styles inspector and my DOM element lines up properly. A OK! However, if try to use jQuery to remove the style via $('#div_appointment_time_picker').removeAttr('float'); or $('#div_appointment_time_picker').removeProperty('float'); respectively (removeAttr and removeProperty) neither of which seem to work. So, basically, how can I programmatically "re-create" what occurs in Google Chrome by unchecking the property in the Style inspector (see img below)

Using Google Chrome Developer Tools I uncheck "float:none;" from the Styles inspector and my DOM element lines up properly. A OK! However, if try to use jQuery to remove the style via $('#div_appointment_time_picker').removeAttr('float'); or $('#div_appointment_time_picker').removeProperty('float'); respectively (removeAttr and removeProperty) neither of which seem to work. So, basically, how can I programmatically "re-create" what occurs in Google Chrome by unchecking the property in the Style inspector (see img below)

Share Improve this question asked Jan 8, 2015 at 17:43 Robert Green MBARobert Green MBA 1,8863 gold badges29 silver badges56 bronze badges 1
  • 1 try using, $('#div_appointment_time_picker').css("float", "none"); – Talha Tanveer Commented Jan 8, 2015 at 17:45
Add a ment  | 

4 Answers 4

Reset to default 4

You can use .css() to change css attributes:

$('#div_appointment_time_picker').css("float", "none");

or to edit multiple properties you can use:

$('#div_appointment_time_picker').css({"float" : "none", "another-rule": "value"});

Float isn't an attribute or property of the element like width or ID is, it's a style property, so you'd have to use $('#div_appointment_time_picker').css('float','none');

$('#div_appointment_time_picker').css('float', 'you are a wizard harry');

Use jQuery method .css();

It works like .css(property, value) or .css({property: value})

For example, in your case it would be:

$('#div_appointment_time_picker').css('float', 'initial'); // or 'none'

Read more about float: https://developer.mozilla/en-US/docs/Web/CSS/float

发布评论

评论列表(0)

  1. 暂无评论