如何在Div中获取每个元素 [英] How to get each element inside a Div

查看:65
本文介绍了如何在Div中获取每个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div。它有一张桌子。它在表格中有输入元素。

我应该如何编写代码,以便使用jQuery .each函数获取所有元素的元素名称和id。当我克隆所有div元素时,需要随机修改克隆元素。



结构就像





文本字段

选择字段

文本字段
文本字段 选择字段


解决方案

试试这个...可能会有点想法..



 


' div table tbody tr') .each( function (){
console .log(


this )。find(' 输入[type = text],选择')。attr(' id'));
console .LOG(

I have a div. It has a table. It has input elements inside the table.
How should i write the code so that i get the elements name and id of all the elements using jQuery .each function. As i am cloning all the div element these are required to modify the cloned element randomly.

structure is like



text field
select field
text field
text fieldselect field

解决方案

Try this ... might give bit idea..


('div table tbody tr').each(function(){ console.log(


(this).find('input[type=text], select ').attr('id')); console.log(


这篇关于如何在Div中获取每个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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