Created
May 23, 2012 00:44
-
-
Save sandro/2772590 to your computer and use it in GitHub Desktop.
playground for testing ios web autofocus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
</head> | |
<body> | |
<a href="">link</a> | |
<input type="text" id="in"/> | |
<button>hi</button> | |
<script type="text/javascript"> | |
$.fn.triggerHTMLEvent = function(type) { | |
var element, event; | |
if (element = this[0]) { | |
if (document.createEvent) { | |
event = document.createEvent('HTMLEvents'); | |
event.initEvent(type, true, true); | |
element.dispatchEvent(event); | |
} else if (element[type]) { | |
element[type](); | |
} | |
} | |
return this; | |
}; | |
$(function() { | |
var x = function(){$('input').focus()}; | |
var auto = function(){$('body').append('<input type="text" autofocus/>')} | |
var field = $('#in'); | |
$('button').click(function() { | |
var newf = $('<input type="password"/>').appendTo($('body')); | |
newf.attr('autofocus', true); | |
newf.show(); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment