I create dynamically textarea element in that way:
var myFrame = $("#description-frame").contents().find('body');
myFrame.html('<textarea id="testowy_desc" rows="4" cols="50" style="border: 2px solid red;"></textarea>');
and after created this element, I want to use trigger - simulate click "k" using keyboard. Here is my code:
if ( $('#testowy_desc').length > 0 )
{
$('#testowy_desc').focus().trigger({ type : 'keypress', which : 75 });
}
else
{
alert('element not exist');
}
But I get: "element not exist". How I can do it?
Thanks.
UPDATE:
Here is part of HTML code:
<iframe id="description-frame" class="valid" frameborder="0">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<style>body {background: #FFFFFF;margin: 0px;padding: 0px;text-align:left;font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 0.875em;}.desc{color:gray;} body.error { background-color: #EFDBD6;} body.valid { background-color: #F0FFC1; color : #468847; } P {margin-top:0;margin-bottom:0}a{text-decoration: none;color:#000}
</style>
</head>
<body id="rte" class="valid">
to jest testowy opis
</p>
</body>
</html>
</iframe>
and this part code looks that:
Screen from firebug console: