jQuery script to move an attribute of matched elements to their children

Posted by UserControl on Stack Overflow See other posts from Stack Overflow or by UserControl
Published on 2010-06-14T06:57:42Z Indexed on 2010/06/14 7:12 UTC
Read the original article Hit count: 214

Filed under:
|
|

I have a set of anchors like

<a class="lb" href="#">text</a>
<a class="lb" href="#" style="width:200px">text</a>
<a class="lb" href="#" style="color: reen; width:200px">text</a>

that needs to be transformed to the following:

<a class="lb" href="#"><span>text</span></a>
<a class="lb" href="#"><span style="width:200px">text</span></a>
<a class="lb" href="#" style="color:green"><span style="width:200px">text</span></a>

I have no problem creating child span but don't know how to move parent's width styling.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html