Adding a ID to a <li> based on part of an <a> tag

Posted by mmsa on Stack Overflow See other posts from Stack Overflow or by mmsa
Published on 2010-04-26T18:34:53Z Indexed on 2010/04/26 18:43 UTC
Read the original article Hit count: 155

Filed under:

I have the following code:

<li class="zoneName"><a href="/Default.aspx?PageID=4869007">CYKF</a></li>
<li class="zoneName"><a href="/Default.aspx?PageID=4868459">YKA</a></li>

I need to add and ID to each of the < li > tags in this list. I need that ID to be the number at the end of the href string. Below is what I'd like it to be

<li class="zoneName" id="4869007"><a href="/Default.aspx?PageID=4869007">CYKF</a></li>
<li class="zoneName" id="4868459"><a href="/Default.aspx?PageID=4868459">YKA</a></li>

Any help is appreciated.

© Stack Overflow or respective owner

Related posts about jQuery