选择列表项< li>使用jQuery的有序列表? [英] Select list item <li> of an ordered list using jquery?

查看:126
本文介绍了选择列表项< li>使用jQuery的有序列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用某种jquery代码来更改 LI 标签的html.

I want to be able to change the html of the LI tag using some kind of jquery code.

想法是,一旦用户登录,就将锚标记的类从"btnsignin"更改为另一个类"btnsignout".

The idea is to change the class of the anchor tag from "btnsignin" to another class called "btnsignout" once the user has logged in.

我将在ajaxForm成功回调函数中使用此代码来更改锚标记的类.

I will use this code inside the ajaxForm success callback function to change the class of anchor tag.

这是我的html:

<div id="top-nav">
<ul class="top-nav">
    <li><a id="login-link" class="btnsignin" title="Login">Admin Zone</a></li>
</ul>
</div>

我的代码应该是什么样?请帮忙,谢谢.

What should my code look like? Please help, thank you.

推荐答案

您可以直接通过其id访问链接,然后链接命令以修改类:

You can access the link directly by it's id and then chain the commands to modify the class:

$('#login-link').removeClass('btnsignin').addClass('btnsignout');

这篇关于选择列表项&lt; li&gt;使用jQuery的有序列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆