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

前端 未结 11 880
暗喜
暗喜 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:37

    Is correct?

    <script>
    $( "#box" ).one( "click", function() {
      $( this ).css( "width", "+=200" );
    });
    </script>
    
    0 讨论(0)
  • 2020-12-08 04:43
     $(this).css({'text-align':'center'}); 
    

    You can use class name and id in place of this

    $('.classname').css({'text-align':'center'});
    

    or

    $('#id').css({'text-align':'center'});
    
    0 讨论(0)
  • 2020-12-08 04:44
    function add_question(){ var count=document.getElementById("nofquest").value; var container = document.getElementById("container"); // Clear previous contents of the container while (container.hasChildNodes()) { container.removeChild(container.lastChild); } for (i=1;i

    how to set center of the textboxes

    0 讨论(0)
  • 2020-12-08 04:45

    I think you should use "textAlign" instead of "text-align".

    0 讨论(0)
  • 2020-12-08 04:47

    suppose below is the html paragraph tag:

    <p style="background-color:#ff0000">This is a paragraph.</p>
    

    and we want to change the paragraph color in jquery.

    The client side code will be:

    <script>
    $(document).ready(function(){
        $("p").css("background-color", "yellow");
    });
    </script> 
    
    0 讨论(0)
提交回复
热议问题