Creating dom elements
Creating dom elements
i've created this which creates a TR and inside has two TD's the second one has a INPUT element inside it. I was just wondering if it can be simplied or optimised in anyway. Also something I noticed in the firebug console is the input tag isn't closed. Any reason for that and is there a fix?
- $tr = $("<tr>");
- /* create a td and append to tr */
$td = $("<td>", {
text: $item.text(),
"css": {
"width": "200px"
}
}).appendTo($tr);
/* Create input box and wrap in td and append to tr */
$input = $("<input>", {
type: "text",
val: $item.val(),
name: "title",
"class": "text",
"css": {
"width": "50px"
}
}).appendTo('<td>').parent().appendTo($tr);