How to dynamically add a style for text-align using jQuery

前端 未结 11 884
暗喜
暗喜 2020-12-08 04:19

I\'m trying to correct the usual IE bugs around CSS 2.1 and need a way to alter an elements style properties to add a custom text-align style.

Currently in jQuery yo

11条回答
  •  心在旅途
    2020-12-08 04:30

    You have the right idea, as documentation shows:

    http://docs.jquery.com/CSS/css#namevalue

    Are you sure you're correctly identify this with class or id?

    For example, if your class is myElementClass

    $('.myElementClass').css('text-align','center');
    

    Also, I haven't worked with Firebug in a while, but are you looking at the dom and not the html? Your source isn't changed by javascript, but the dom is. Look in the dom tab and see if the change was applied.

提交回复
热议问题