jquery中children()方法如何使用

2024-10-22 22:07:49

1、新建一个html文件,命名为test.html,用于讲解jquery中children()方法如何使用。

jquery中children()方法如何使用

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

jquery中children()方法如何使用

5、在js标签内,创建getCild()函数,在函数内,通过id获得div对象,使用children()方法获得div内的子元素对象,再通过text()方法获得子元素的内容。最后,使用alert()方法输出内容。

jquery中children()方法如何使用
猜你喜欢