从javascript变量获取InnerHtml [英] Getting InnerHtml from a javascript Variable
本文介绍了从javascript变量获取InnerHtml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从页面上进行了ajax调用,然后作为响应,我也得到了一些类似的html
I make an ajax call from my page , and then in response I also get some html like this
<parent id="1"><child></child></parent>
我想要的是从Response对象中获取内部HTML,但不包括<parent>
我怎样才能做到这一点?
不能在变量上使用document.getElementbyID
.
what I want is to get Inner HTML from the Response object excluding <parent>
How can I do that?
Cant use document.getElementbyID
on a variable.
推荐答案
you can create a jQuery wrapper for the variable content and then extract the inner html using .html()
var data = '<parent id="1"><child></child></parent>'
var x = $(data).html()
这篇关于从javascript变量获取InnerHtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文