creando open tr y td jquery
Frecuentes
Visto 85 equipos
-1
I am having trouble converting inline html in my javascript to jquery.
I want to avoid inline scripts so firebug will not show the entire script in one row and instead keeps the formatting.
Basically i have this at the moment:
var zeile2 = $("<tr id='wle_focusout_"+paramDataObject.id+"'>" +
"<td><input id='wle_input_seconds_"+paramDataObject.id+"' type='text'/> </td>" +
"<td><input id='wle_input_height_"+paramDataObject.id+"' type='text'/> </td>" +
"<td><input id='"+get_waterlevelevent_del_btn_name(paramDataObject.id)+"' type='button' value='"+languagebox.editor_wleRemoveBtn_header+"'/> </td>" +
"</tr>");
One tr with 3 tds, each td has an input element in it.
So far I converted each element on its own:
var wleFocusOut = $(document.createElement('tr')).attr({
id: 'wle_focusout_'+paramDataObject.id,
});
var wleInputSec = $(document.createElement('input')).attr({
id: 'wle_input_seconds_'+paramDataObject.id,
type: 'text'
});
var wleInputHeight = $(document.createElement('input')).attr({
id: 'wle_input_height_'+paramDataObject.id,
type: 'text'
});
var wleDelBtn = $(document.createElement('input')).attr({
id: get_waterlevelevent_del_btn_name(paramDataObject.id),
value: languagebox.editor_wleRemoveBtn_header,
type: 'button'
});
var wleTempTd = $(document.createElement('td'));
However those jquery elements are closed (without body content).
How can i create an open () version with jquery that allows me to add(just append?) the tds, etc?
1 Respuestas
0
Encontré la solución:
var zeile2 =
$('<tr/>', {'id':'wle_focusout_'+paramDataObject.id}
).append(
$('<td/>').append(
$('<input/>',{
'id': 'wle_focusout_'+paramDataObject.id})
)
).append(
$('<td/>').append(
$('<input/>',{
'id': 'wle_input_seconds_'+paramDataObject.id,
'type': 'text'})
)
).append(
$('<td/>').append(
$('<input/>',{'id': 'wle_input_height_'+paramDataObject.id,
'type': 'text'})
)
).append(
$('<td/>').append(
$('<input/>',{'id': get_waterlevelevent_del_btn_name(paramDataObject.id),
'value': languagebox.editor_wleRemoveBtn_header,
'type': 'button'})
)
);
With this different syntax it does work and firebug does not assume this beeing inline script.
Respondido el 13 de junio de 14 a las 12:06
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas javascript jquery html or haz tu propia pregunta.