条件满足时检查复选框

How to check the checkbox when condition satisfies?

<input name="pt_id[]" id="pt_id" type="checkbox" value="<?php echo the_ID(); ?>" <?php if(isset($_POST["pt_id"])) { echo 'checked="checked"'; } ?>/>&nbsp;<?php echo the_title(); ?>

Please help me. Give me solution or suggestion for this?

Well your code already does what you need but using PHP. If you want to catch an event lets say user clicks on a div and you want to check the checkbox then you need to use javascript/jquery.

sample code would be (using jquery):

$(document).on('click', '#yourdiv', function() {
   $('#pt_id').attr('checked', true);
});

this will check the checkbox when yourdiv is clicked

if you wish to uncheck it when div2 is clicked do this:

$(document).on('click', '#div2', function() {
  $('#pt_id').attr('checked', false);
});