jQuery get checkbox value if checked and remove value when unchecked

You don't need an interval, everytime someone changes the checkbox the change event is fired, and inside the event handler you can change the HTML of #show based on wether or not the checkbox was checked :

$('#check').on('change', function() {
    var val = this.checked ? this.value : '';
    $('#show').html(val);
});

FIDDLE


Working Demo http://jsfiddle.net/cse_tushar/HvKmE/5/

js

$(document).ready(function(){
    $('#check').change(function(){
        if($(this).prop('checked') === true){
           $('#show').text($(this).attr('value'));
        }else{
             $('#show').text('');
        }
    });
});

There is another way too:

  1. Using the new property method will return true or false.

    $('#checkboxid').prop('checked');

  2. Using javascript without libs

    document.getElementById('checkboxid').checked

  3. Using the JQuery's is()

    $("#checkboxid").is(':checked')

  4. Using attr to get checked

    $("#checkboxid").attr("checked")

i prefer second option.