Javascript jQuery对象转换为字符串
请帮我解决一个jquery对象问题 问题如下,我有以下代码:Javascript jQuery对象转换为字符串,javascript,jquery,Javascript,Jquery,请帮我解决一个jquery对象问题 问题如下,我有以下代码: url = '<a href="http://url.com">Name</a>'; otherValue = "Other Value"; x = jQuery(url).text(otherValue); console.log(x); console.log(typeof(x)); url=”; otherValue=“其他值”; x=jQuery(url).text(otherVa
url = '<a href="http://url.com">Name</a>';
otherValue = "Other Value";
x = jQuery(url).text(otherValue);
console.log(x);
console.log(typeof(x));
url=”;
otherValue=“其他值”;
x=jQuery(url).text(otherValue);
控制台日志(x);
控制台日志(类型(x));
本申报表:
[<a href="http://url.com">Other Value</a>]
object
[]
对象
我是如何将这个对象转换成字符串的
Thank's试试console.log(x[0].outerHTML);
解释:x[0]
为您提供htmlanchoreElement
对象,htmlanchoreElement.outerHTML
为您提供html字符串。查看此链接
url = '<a href="http://url.com">Name</a>';
otherValue = "Other Value";
x = jQuery(url).text(otherValue);
alert(x[0].outerHTML);
url=”;
otherValue=“其他值”;
x=jQuery(url).text(otherValue);
警报(x[0].outerHTML);
您是否正在尝试获取
的字符串表示形式是!!我想要获取字符串表示形式!!现在我遇到了一个问题:可能比outerHTML替换我“>”