Reputation: 817
I believe in this case I'm simply lacking knowledge on some point. I am trying to simulate a few different event types when a user clicks into an input field. I am using jquery to accomplish this. However, at the moment I'm getting a generic "undefined" error.
HTML:
<input id="test" type="text" name="test" />
Javascript:
$(function () {
$('#test').click(function () {
$('#test').keydown();
$('#test').focus();
$('#test').change();
});
});
$(function () {
('#test').on('keydown', function(){
$('<p>test!</p>').insertAfter('#test');
});
});
Here is a jsfiddle with the code I'm attempting to use.
http://jsfiddle.net/PhantomDude95/P55Xw/1/
Upvotes: 0
Views: 41
Reputation: 18099
You just missed $
sign in your selector! And I think you didn't included jquery in fiddle.
Demo: http://jsfiddle.net/P55Xw/2/
$(function () {
$('#test').click(function () {
$('#test').keydown();
$('#test').focus();
$('#test').change();
});
});
$(function () {
$('#test').on('keydown', function(){ //Here you missed the $ sign for selector
$('<p>test!</p>').insertAfter('#test');
});
});
Upvotes: 1