+ var select = jQuery("select[name='S1']")
+ select.live("change", function() {
+ selectChange++;
+ });
+
+ var checkbox = jQuery("#check2"),
+ checkboxFunction = function(){
+ checkboxChange++;
+ }
+ checkbox.live("change", checkboxFunction);
+
+ // test click on select
+
+ // first click sets data
+ if ( !jQuery.support.changeBubbles ) {
+ select[0].selectedIndex = 1;
+ select.trigger("keyup");
+ }
+
+ // second click that changed it
+ selectChange = 0;
+ select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
+ select.trigger(jQuery.support.changeBubbles ? "change" : "click");
+ equals( selectChange, 1, "Change on click." );
+
+ // test keys on select
+ selectChange = 0;
+ select[0].selectedIndex = select[0].selectedIndex ? 0 : 1;
+ select.trigger(jQuery.support.changeBubbles ? "change" : "keyup");
+ equals( selectChange, 1, "Change on keyup." );
+
+ // test click on checkbox
+ checkbox.trigger(jQuery.support.changeBubbles ? "change" : "click");
+ equals( checkboxChange, 1, "Change on checkbox." );
+
+ // test before activate on radio
+
+ // test blur/focus on textarea
+ var textarea = jQuery("#area1"), textareaChange = 0, oldVal = textarea.val();
+ textarea.live("change", function() {
+ textareaChange++;
+ });
+
+ if ( !jQuery.support.changeBubbles ) {
+ textarea.trigger("focus");
+ }
+
+ textarea.val(oldVal + "foo");
+ textarea.trigger(jQuery.support.changeBubbles ? "change" : "blur");
+ equals( textareaChange, 1, "Change on textarea." );
+
+ textarea.val(oldVal);
+ textarea.die("change");
+
+ // test blur/focus on text
+ var text = jQuery("#name"), textChange = 0, oldTextVal = text.val();
+ text.live("change", function() {
+ textChange++;
+ });
+
+ if ( !jQuery.support.changeBubbles ) {
+ text.trigger("focus");
+ }
+
+ text.val(oldVal+"foo");
+ text.trigger(jQuery.support.changeBubbles ? "change" : "blur");
+ equals( textChange, 1, "Change on text input." );
+
+ text.val(oldTextVal);
+ text.die("change");
+
+ // test blur/focus on password
+ var password = jQuery("#name"), passwordChange = 0, oldPasswordVal = password.val();
+ password.live("change", function() {
+ passwordChange++;