错误:对象没有方法换行 [英] Error: object has no method wrap

查看:117
本文介绍了错误:对象没有方法换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Chrome控制台错误:对象没有方法换行

chrome console error : object has no method wrap

$('.dropdown_menu_header_n').append($(this).children('div').clone().text().wrap('<a></a>'));

请帮助我添加一个用<a></a>

推荐答案

.text()返回字符串,而不是jQuery对象.另外,.wrap()返回原始的jQuery元素,而不是包装的元素.

.text() returns a string, not a jQuery object. Also, .wrap() returns the original jQuery element, not the wrapped one.

尝试一下:

$('.dropdown_menu_header_n').append($(this).children('div').clone().wrap('<a></a>').parent());

或者如果要包装内容,请尝试.wrapInner:

Or if you want to wrap the contents, try .wrapInner:

$('.dropdown_menu_header_n').append($(this).children('div').clone().wrapInner('<a></a>'));

这篇关于错误:对象没有方法换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆