Remove attribute of HTML tag

后端 未结 6 2364
无人及你
无人及你 2020-12-01 18:45

Is it possible to remove the attribute of the first HTML

tag? So, this:

aaa
6条回答
  •  無奈伤痛
    2020-12-01 18:52

    To remvove it from literally the first element use .removeAttr():

    $(":first").removeAttr("style");
    

    or in this case .show() will show the element by removing the display property:

    $(":first").show();
    

    Though you probably want to narrow it down to inside something else, for example:

    $("#container :first").removeAttr("style");
    

    If you want to show the first hidden one, use :hidden as your selector:

    $(":hidden:first").show();
    

提交回复
热议问题