У меня возникли некоторые проблемы с focus (function () {})
и blur (function () {})
внутри скрипта, который вложен в динамически загружаемый iframe ..
Ниже показан тег скрипта ВНУТРИ динамически загружаемого iframe. Любое событие, которое я добавляю в разметку скрипта, не работает, простые вещи вроде $ ('input'). Click (function () {alert ('fired')});
даже не запустятся. Я не понимаю, что происходит.
Да, jQuery загружается в iframe в заголовке.
<script type="text/javascript">
// <![CDATA[
$(document).ready(function() {
$('.form .field-content').find('input, select, textarea').focus(function() {
$(this).closest('.field').addClass('focused');
});
$('.form .field-content').find('input, select, textarea').blur(function() {
$(this).closest('.field').removeClass('focused');
});
$('.form .field-content').find('input, select').keypress(function(e) {
if (e.which == 13) {
e.preventDefault();
$(this).closest('.form').find('.button').first().click();
}
});
$('.form .button').focus(function() {
$(this).addClass('focused');
});
$('.form .button').blur(function() {
$(this).removeClass('focused');
});
// focus on first field
$('.form .field-content').find('input, select, textarea').first().focus();
});
// ]]>
</script>