how to run click function after default behaviour of a element

Posted by Somebody is in trouble on Stack Overflow See other posts from Stack Overflow or by Somebody is in trouble
Published on 2012-06-22T15:03:58Z Indexed on 2012/06/22 15:16 UTC
Read the original article Hit count: 241

Filed under:
|
|

My code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script src="jquery.js"></script>
<script>
$(function(){
    $("body").on("click",".mes_sel",function(){
        if($(".mes_sel:checked").length==0){
            alert("Checked");
        }
        else alert("Not Checked");
    });
});
</script></head>
<body>
<input type="checkbox" class="mes_sel">
</body>
</html>

It is alerting checked when the textbox is unchecked because onclick is running before the checking of checkbox.How can i make the click event to run after checking/unchecking of the input

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery