JQuery中如何给span标签加class属性

2024-11-01 03:13:34

1、新建一个html文件,命名为test.html,用于讲解JQuery中如何给span标签加class属性。

JQuery中如何给span标签加class属性

3、在test.html文件内,给span标签添加一个id属性,用于获得对象。

JQuery中如何给span标签加class属性

5、在js标签中,创建addcc()函数,在函数内,通过id获得 span对象,使用attr()方法设置p标签的class属性为myclass。

JQuery中如何给span标签加class属性JQuery中如何给span标签加class属性
猜你喜欢