Skip to main content

Bug Tracker

Side navigation

Ticket #5055: resptest.html
File resptest.html, 1.0 KB (added by william_mc, August 15, 2009 10:13AM UTC)
<head>
<script src="jquery-1.3.1.js"></script>
<script>


// The setTimeout calls in setting focus are only necessary in IE.
// Without them the resetting of focus is erratic, and depends on who
// previously had the focus.

function putbutton() {
  $('#resp').html('<button id="clickme">click me</button>');
  setTimeout( function() {$('#clickme').focus()},0)
  // not enclosing $('#clickme').focus() in setTimeout doesn't work all the time
}

function putinput() {
  $('#resp').html('<input type="text" width=20 id="typeme" name="typeme"/>');
  setTimeout( function() {$('#typeme').focus()},0)
  // not enclosing $('#typeme').focus() in setTimeout doesn't work at all
}



$(document).ready( function() {

  $('#change2button').click( putbutton );
  $('#change2input').click( putinput );

} 
);

</script>
<body>
<button id="change2button">change to a button</button>
<button id="change2input">change to an input</button><br />
<span id="resp">Click one of the buttons to change me to a control</span>
</body>

Download in other formats:

Original Format