Problem upgrading from 1.2.6 to 1.4

Problem upgrading from 1.2.6 to 1.4

Hi, I'm using 1.2.6, and I have a code essentially like this:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script>
function clk(o) {
  if (o.checked) $(o).parent().css("border", "3px solid black");
  else $(o).parent().css("border-width", "0px");
}
function chg(n) {
  $("#cbx"+n).click();
}
</script>
</head>
<body>
<span><input id="cbx1" type="checkbox" onclick="clk(this)"></span>
<span><input id="cbx2" type="checkbox" onclick="clk(this)"></span>
<input onchange="chg(1)">
<input onchange="chg(2)">
</body>
</html>

So basically this will put a border around the checkbox if it is checked. If you change the corresponding textbox, it will also simulate checkbox click (which in turn will put/remove border around the checkbox). You can try it using Tryit Editor (http://www.w3schools.com/HTML/tryit.asp?filename=tryhtml_basic)

Anyway, I'm trying to upgrade it to jQuery 1.4.1, which essentially only changes this line:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>

(from 1.2.6 to 1.4.1).

When I run it, the checkbox click event's behavior is the same. However, the textbox change event is now different: ie. it will check/uncheck the checkbox, but the border effect is only done after the second time this event is fired.

For example:

1. Type "a" in the textbox -> it will check the box, BUT it doesn't put a border on it
2. Change "a" to "ab" in the textbox -> it will uncheck the box, BUT it will also put a border on it.

Can anybody help me on how to fix this? Is this jquery bug or my program's? (but it works fine on 1.2.6 :<)

Thanks.