Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  130] [ 5]  / answers: 1 / hits: 34791  / 14 Years ago, mon, october 11, 2010, 12:00:00

Is it possible to remove the attribute of the first HTML <div> tag? So, this:



<div style=display: none; >aaa</div>


becomes



<div>aaa</div>


from the following:



<div style=display: none; >aaa</div>
<a href=# style=display: none; >(bbb)</a>
<span style=display: none; >ccc</span>​

More From » jquery

 Answers
12

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();

[#95354] Friday, October 8, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aileenreynap

Total Points: 140
Total Questions: 106
Total Answers: 99

Location: Andorra
Member since Sun, Oct 18, 2020
4 Years ago
;