开发者

jQuery - Assign a html code to a variable

开发者 https://www.devze.com 2023-01-28 12:07 出处:网络
Suppose I have a code like that <p&开发者_开发问答gt;hello</p> I want to assign the above code to a variable, how to do that?var content = $(\'p\').html();

Suppose I have a code like that

<p&开发者_开发问答gt;hello</p>

I want to assign the above code to a variable, how to do that?


var content = $('p').html();

Ah dammit, too late.

If you want a specific paragraph you should give it an id and use:

var content = $('p#id').html();

instead.


var a = "<p>hello</p>";
0

精彩评论

暂无评论...
验证码 换一张
取 消