jQuery Duplicate Selector error
Actualmente estoy intentando configurar una tabla con 6 celdas seleccionables que permiten que aparezca un cuadro de entrada para que pueda agregar comentarios, pero obtengo un error de jQuery selector duplicado y también, al depurar mi segunda función, encontré que.html()
Tampoco está funcionando. Aquí está mi código para las 6 funciones; cada uno de los cuales se llama cuando se hace clic en una celda específica:
$("#mondayCommentLink").click(function (){
var mondayhtmls = $("#mondayComment");
var input = $("<input type='text' id='mondayCommentText' name='mondayCommentText' />");
input.val(data.days[0].comment);
mondayhtmls.html(input);
});
$("#tuesdaysCommentLink").click(function (){
var tuesdayhtmls = ("#tuesdayComment");
var inputt = $("<input type='text' id='tuesdayCommentText' name='tuesdayCommentText' />");
inputt.val(data.days[1].comment);
tuesdayhtmls.html("test");
});
$("#wednesdayCommentLink").click(function (){
var htmls = ("#wednesdayComment");
var input = $("<input type='text' id='wednesdayCommentText' name='wednesdayCommentText' />");
input.val(data.days[2].comment);
htmls.html(input);
});
$("#thursdayCommentLink").click(function (){
var htmls = ("#thursdayComment");
var input = $("<input type='text' id='thursdayCommentText' name='thursdayCommentText' />");
input.val(data.days[3].comment);
htmls.html(input);
});
$("#fridayCommentLink").click(function (){
var htmls = ("#fridayComment");
var input = $("<input type='text' id='fridayCommentText' name='fridayCommentText' />");
input.val(data.days[4].comment);
htmls.html(input);
});
$("#saturdayCommentLink").click(function (){
var htmls = ("#saturdayComment");
var input = $("<input type='text' id='saturdayCommentText' name='saturdayCommentText' />");
input.val(data.days[5].comment);
htmls.html(input);
});
Y aquí es de donde son llamados:
<th id="mondayComment" name="mondayComment" style="text-align: center; width: 115px;"><div id="mondayCommentLink">+</div></th>
<th id="tuesdayComment" name="tuesdayComment" style="text-align: center; width: 115px;"><div id="tuesdaysCommentLink">+</div></th>
<th id="wednesdayComment" name="wednesdayComment" style="text-align: center; width: 115px;"><div id="wednesdayCommentLink">+</div></th>
<th id="thursdayComment" name="thursdayComment" style="nowrap; text-align: center; width: 115px;"><div id="thursdayCommentLink">+</div></th>
<th id="fridayComment" name="fridayComment" style="text-align: center; width: 115px;"><div id="fridayCommentLink">+</div></th>
<th id="saturdayComment" name="saturdayComment" style="text-align: center; width: 115px;"><div id="saturdayCommentLink">+</div></th>
No entiendo por qué recibo un error de selector duplicado en#mondayCommentLink
, #tuesdayCommentLink
, etc. ¿Hay algo que me falta o que estoy haciendo mal por error? La primera celda funciona y puedo hacer clic en ella y aparecerá un cuadro de entrada, pero falla en la segunda celda#tuesdayCommentLink
en la lineatuesday.htmls.html("test");
.