正在获取未捕获的类型错误
Getting an Uncaught TypeError
我有以下代码。除了这一行之外,一切都很好不确定为什么我在这一行上得到Uncaught TypeError错误
this.find('iframe').contents().find('body').css('background-color', settings.color);
尤其是console.log(this)正确地输出了元素。我是jQuery的新手,所以这可能是我没有看到的明显的东西。
jQuery(document).ready(function($) {
$('div[data-name*="form_background_colour"] input.wp-picker-clear').click(function() {
$(this).setDefaultFormEditorBackground();
});
});
jQuery.fn.extend({
setDefaultFormEditorBackground: function (options) {
var settings = jQuery.extend({
color: ""
}, options );
var $colorpicker_input = this;
var $bgcolor_div = $colorpicker_input.closest('div[data-name*="form_background_colour"]');
$bgcolor_div.nextAll('[data-type="wysiwyg"]:lt(2)').each(function() {
console.log(this);
console.log($colorpicker_input);
this.find('iframe').contents().find('body').css('background-color', settings.color);
$colorpicker_input.closest('.wp-picker-container').find('.wp-color-result').css('background-color', settings.color);
});
}
});
each()
回调中的this
将是元素本身,而不是它们的jQuery包装器。
你需要这样做:
jQuery(this).find('iframe').contents().find('body').css('background-color', settings.color);
相关文章:
- 为什么会出现错误;未捕获的类型错误:undefined不是函数;
- 同样,同样的错误'ahorcado.js:26未捕获类型错误:无法读取属性'beginPath'
- 未捕获的类型错误:无法读取属性'删除'的未定义
- 未捕获的类型错误:无法读取属性'name'即使它存在,也无法定义
- 看到“;未捕获的类型错误:无法读取属性'weight'未定义的“;尽管按照字面上的指示
- Soundcloud api"未捕获的类型错误:无法读取属性'uri'“未定义”;
- 未捕获的类型错误:无法读取属性'addEventListener'的null chrome扩展名
- 如何解决这种情况下的非法调用类型错误
- 未捕获的类型错误:$(..).dataTable不是函数
- 未捕获的类型错误:无法读取属性'状态'在react中为null
- 未捕获的类型错误:topFrame.window.changeSelectedBarStyle不是函数,原因是什么
- 类型错误:url未定义extjs 4正在填充组合框
- 未捕获的类型错误:无法读取属性'中止'的未定义
- 类型错误'未定义'不是对象(正在评估'navigator.connection.type'
- 未捕获的类型错误:无法设置属性'innerHTML'如果为null,则将脚本移动到正文不会;不起作用
- 未捕获的类型错误:undefined不是函数$
- 输入类型文件的未捕获类型错误
- 未捕获的类型错误:无法设置属性'背景'的未定义
- "未捕获类型错误/丢弃意外“;因为一句台词而出现?(HTML w/<脚本>)
- Javascript未捕获类型错误:无法读取属性'0'的未定义