My table looks like this.
<input type=checkbox onclick=enableEdit(this)/>
<tr>
<td onclick=enableInput(this)>
<input style="display:none">
<span>text1</span>
</td>
<td onclick=enableInput(this)>
<input style="display:none">
<span>text2</span>
</td>
<td>
<img class='iconPlus' onclick=disableInput(this)/>
</td>
</tr>
function enableInput(t){
$(t).closest('tr').find('input').show()
$(t).closest('tr').find('span').hide()
}
function disableInput(t){
$(t).closest('tr').find('span').show()
$(t).closest('tr').find('input').hide()
}
function enableEdit(elm){
if($(elm).is(':checked'){
$('.iconPlus').removeAttr('onclick')
$('td').removeAttr('onclick')
}else{
$('.iconPlus').attr('onclick', 'disableInput(this)')
$('td').attr('onclick','enableInput(this)')
} }
Before checking the checkbox, I click each td
to show input
and hide span
. Then when I click the img
, it hides input
and shows span
.
However, after checking and unchecking the checkbox to disable input, I am unable to hide the input
and show the span
when clicking on a td
.
Upon checking the console, the input
is displaying as display:inline-block
instead of none
.
I hope you understand my issue.
Any suggestions or help would be greatly appreciated.