Reputation: 123
I keep receiving error of illegal character in firebugs
$('#service_chk').click(function () {
var $this = $(this);
if ($this.is(':checked')) {
$('#service').css('display','block');
} else {
$('#service').css('display','none');
}
});
Error keep pointing "coma" in $('#service').css('display','block');
and this is my view
<tr>
<td><input type="checkbox" id="service_chk"></td>
<td style="text-align:center;"><input type="text" class="form-control" id="service" style="display:none;"></td>
</tr>
Im on the way learning javascript, please help me, thanks.
Upvotes: 2
Views: 5140
Reputation: 18099
Issue is because of encoding in your text editor or the IDE which you are using. Copy paste your script into jsfiddle and you'll see the errors.
HTML
<tr>
<td>
<input type="checkbox" id="service_chk">
</td>
<td style="text-align:center;">
<input type="text" class="form-control" id="service" style="display:none;">
</td>
</tr>
Link: http://jsfiddle.net/GCu2D/1655/
Upvotes: 6
Reputation: 177
you have a bunch of invisible spaces (zero width spaces) in your code.
below is the fixed version of your code:
$('#service_chk').click(function () {
var $this = $(this);
if ($this.is(':checked')) {
$('#service').css('display','block');
} else {
$('#service').css('display','none');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<tr>
<td><input type="checkbox" id="service_chk"></td>
<td style="text-align:center;"><input type="text" class="form-control" id="service" style="display:none;"></td>
</tr>
Upvotes: 0