Does anyone have any idea what I could be doing wrong? why this basic click function isn’t getting executed to the point of sending off the alert. I have jQuery-1.7.1.js linked to my page.
jQuery
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="../fruith/jquery-1.7.1.js"></script>
<script type="text/javascript">
function checkedDark () {
$('#activate_post_checkbox').click(function(){
alert('duh')
$('#work').css('color', this.checked ? '#000' : '#666');
});
}
</script>
</head>
HTML
<body>
<div id="work">blah blah blah</div>
<input type="checkbox" id="activate_post_checkbox" value="active" /><span id="activate_post_checkbox_text">Make my posting active immediately.</span>
</body>
</html>
You need to assign the click event in the
document.readyfunction, or call yourcheckedDark()function first.For example: