Reputation: 3224
I'm not sure if the change method is the correct to use. What i want is if the checkbox is clicked(checked) the html of the textarea is var two and if the checkbox is unchecked the html of the textarea is var one. How do i accomplish this?
<script type="text/javascript">
$(function() {
$('.image').change(function() {
var one='type information here';
var two='type url here';
if($('.information').html=='type information here') {
$('.information').html('type url here');
} else {
$('.information').html('type information here');
}
});
});
</script>
<input type="checkbox" class="image"/>
<textarea class="information">type information here</textarea>
Upvotes: 1
Views: 153
Reputation: 348992
Use .val()
instead of .html()
. Also, notice that you've forgot the parentheses in your if
-condition.
$(function() {
$('.image').change(function() {
var one='type information here';
var two='type url here';
if($('.information').val() == one) {
$('.information').val(two);
} else {
$('.information').val(one);
}
});
});
Upvotes: 3