开发者

uncheck a checkbox with jquery during an change event

开发者 https://www.devze.com 2023-04-13 08:32 出处:网络
im trying to uncheck programaticaly a checkbox while in a change event: $(\"#tar开发者_Go百科get\").change(function() {

im trying to uncheck programaticaly a checkbox while in a change event:

  $("#tar开发者_Go百科get").change(function() {

      $("#hide_image").attr('checked', false);  //nor working




  $.ajax({
  url: "evenements_admin_ajax.php?action=edit_evenement",
  data: "id="+this.value,
  success: function(html){
    response= html.split("|");
     $("#evenements_nom").val(response[0]);
    $("#date_debut").val(response[1]);
      $("#date_fin").val(response[2]);
      $("#desc_evenement").val(response[3]);
         $("#thumbnail").html(response[4]);
       }
    })
})

HTML:

<select name="id" id="target">
<option value="not">choisir un événement</option>
<?php
$h=mysql_query("select evenements_id, evenements_nom from evenements");
 while($hr=mysql_fetch_array($h)){
?>
<option value="<?php echo $hr["evenements_id"]; ?>" <?php if($_POST["id"]==$hr["evenements_id"] and $_POST["modifier_evenement"]) echo 'selected="selected"' ?> ><?php echo $hr["evenements_nom"]; ?></option>

 <?php } ?>
</select>

thanks for your help


If your using jQuery 1.6+ then you should be using the prop() method

$("#hide_image").prop('checked', false);

If using jQuery lower than 1.6 then you could use the following

$("#hide_image").attr('checked', 'checked');


you can try this.

$("#hide_image").removeAttr('checked')
0

精彩评论

暂无评论...
验证码 换一张
取 消