I am currently trying to set up a table with 6 clickable cels that allow for a input box to appear so you can add comments but I am getting a duplicated jQuery selector error and also through debugging my second function I found that .html()
is not working either. Here is my code for the 6 functions; each of which are called when a specific cell is clicked:
$("#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);
});
And this is where they are called from:
<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>
I don't understand why I am getting a duplicate selector error on #mondayCommentLink
, #tuesdayCommentLink
, etc. Is there something I'm missing or mistakenly doing wrong? The first cell works and I can click it and a input box will pop up but it fails upon the second cell #tuesdayCommentLink
at the line tuesday.htmls.html("test");
.
question from:
https://stackoverflow.com/questions/16863844/jquery-duplicate-selector-error 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…