[英]alert gives [object NodeList]
I have a function in Javascript & jQuery . 我在Javascript和jQuery中有一个功能。
dynamic_link = $j('#dynamic_link_add_btn').parent().parent().parent().parent()
.children('tbody').html();
function add_tier (t,html_handle){
alert(html_handle);
$j(t).parent().parent().parent().parent()
.children('tbody').append(html_handle);
}
It is called by onclick="add_tier(this,dynamic_link)"
: 它由
onclick="add_tier(this,dynamic_link)"
调用:
<td class="a-right" colspan="4">
<button class="scalable add" type="button" id="dynamic_link_add_btn" onclick="add_tier(this,dynamic_link)">
<span>Add Extra Links</span>
</button>
</td>
Handles dynamic form fields (appending HTML, to be more precise). 处理动态表单字段(更准确地说,附加HTML)。
It should add the HTML it gets from the dynamic_link
variable to the designated place. 它应该将从
dynamic_link
变量获取的HTML添加到指定位置。 It works fine with other rows. 它可以与其他行一起正常工作。 Rows have multiple input boxes and checkboxes.
行具有多个输入框和复选框。
The alert gives out [object NodeList]
. 警报发出
[object NodeList]
。
Iterated the NodeList
. 迭代
NodeList
。 It doesn't return the HTML (I am not sure that it even does that task). 它不返回HTML(我不确定它是否可以执行该任务)。
NOTE: The form is really a big one. 注意:该表格确实是一个很大的表格。 There are many
dynamic_link
type variables which stores HTML. 有许多
dynamic_link
类型变量可存储HTML。 I have also compared character by character between the working and the not working LOC. 我还比较了正常工作和不工作的LOC之间的每个字符。
Edit : $j
is just the $
of jQuery. 编辑 :
$j
只是jQuery的$
。 It's been defined with jQuery.noConflict. 它是使用jQuery.noConflict定义的。
first of all you can use jQuery
instaed of $j
. 首先,您可以使用
$j
jQuery
instaed。 that way you don't need to add jQuery.noConflict
这样,您无需添加
jQuery.noConflict
then another point 然后另一点
instead of using 而不是使用
dynamic_link = $j('#dynamic_link_add_btn').parent().parent().parent().parent().children('tbody').html();
very easily you can use 很容易就可以使用
dynamic_link = jQuery('#dynamic_link_add_btn').parents('.class_name').children('tbody').html();
class_name is the class name of your parent
element that you want to select. class_name是要选择的
parent
元素的类名。
then you can try 那你可以试试
jQuery('#dynamic_link_add_btn').live('click',function(){
var dynamic_link = jQuery(this).parents('.class_name').children('tbody').html();
alert(dynamic_link);
jQuery(this).parents('.class_name').children('tbody').append(dynamic_link);
});
to give a specific solution , you should post your HTML 要提供特定的解决方案,您应该发布HTML
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.