0

I want to remove the click event from select list and from jQuery date picker. Say if a select box contains 3 values (Select, Yes, No) No is selected when the form is loaded then the user must not be able to change it until a satisfying condition is met. Once the condition is met also I want to restore the selection of any option.

<html>
<head> 
<title> Javascript Test </title>
<script src="jquery.js"> </script>
<script type="text/javascript">
$(document).ready(function(){

$("#b1").data("isOn","Remove");
});

$(document).ready(function(){




    $("#b1").click(function(){
    var i=0;
    //alert("hi");
    if($(this).data("isOn")=="Add"){
        alert($(this).data("isOn"));
        $(this).data("isOn",'Remove');
        $("#car").on('click');
        //return false;
    }
    else if($(this).data("isOn")=="Remove"){
        alert($(this).data("isOn"));
        $("#car").off("click");
        $(this).data("isOn",'Add');
        //return false;
    }
    alert(i);
    i++;
    });
    
});
    

</script>


</head>
<body>
<select name="carlist" form="carform" id="car">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>
<input type = "button" value="Add/Remove" id="b1"/>
</body>
</html>
2
  • Have you got code that you've tried? Sep 17, 2013 at 7:19
  • I have given a sample code above, though I have used a workaround for the same. Sep 17, 2013 at 9:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.