I have this little jquery function:
$.each($('#TableBody tr:gt(0)'), function(index, element){
element.find('td').last().html($('<span/>', {class: "input-group-addon", text: 'Auswählen'}));
});
Somehow i get this error in the first line:
Uncaught TypeError: undefined is not a function
I tried some things in the console to fix this problem! But somehow nothing worked!
Now i hope you can help me! JSFIDDLE: http://jsfiddle.net/3C98M/
Thanks
element
is not a jQuery object, the second argument of the $.each
function returns the native DOM node
$.each($('#TableBody tr:gt(0)'), function(index, element){
$(element).find('td').last().html($('<span/>', {"class": "input-group-addon", text: 'Auswählen'}));
});
Also note that class
is a reserved keyword in javascript and should be quoted.
It could also be written
$('#TableBody tr:gt(0)').each(function(index, element) {
$(element).find('td').last().html(
$('<span/>', {
"class" : "input-group-addon",
text : 'Auswählen'
})
);
});
which is more readable IMO.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With