code_junkie

Why can't I focus a control that I reveal with slideDown()?

Nov 12th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. $("document").ready(function(){
  2. $("#MyButton").click(function(e){
  3. e.preventDefault();
  4. $(".SlidingDiv").slideDown();
  5. $("#MyInput").focus();
  6. });
  7. });
  8.  
  9. <input type="button" value="Click Me" id="MyButton" />
  10. <div class="SlidingDiv" style="display:none;"><input type="text" id="MyInput" /></div>
  11.  
  12. $(function(){
  13. $("#MyButton").click(function(e){
  14. e.preventDefault();
  15. $(".SlidingDiv").slideDown(function(){
  16. // Callback function - will occur when sliding is complete.
  17. $("#MyInput").focus();
  18. });
  19. });
  20. });
Add Comment
Please, Sign In to add comment