在div中选择<a>

Dis*_*eae 0 html jquery if-statement

我想选择活动类的URL的ID.

情况是这样的:

<ul id="links">
 <li id="active"> <a href="#" id="3"> </li>
 <li id="">       <a href="#" id="2"> </li>
 <li id="">       <a href="#" id="3"> </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

jQuery的:

if (jQuery("#links li").is('#active')) {
          *do this*
}
Run Code Online (Sandbox Code Playgroud)

jQuery需要获取LI获得ID"活动"的A的ID,但我无法弄清楚如何执行此操作.这有可能实现吗?

Moh*_*dil 5

var id = jQuery("#links li#active a").attr("id");
Run Code Online (Sandbox Code Playgroud)

演示--> http://jsfiddle.net/xtzj7/