Reputation: 22489
I have an iframe
and I want to get the head content value.
<iframe>
<html>
<head>
<style>body{color:red;}</style>
<link type="text/css" rel="stylesheet" href="some link">
</head>
</html>
</iframe>
I tried this script:
var sett_wped_head = jQuery('iframe').contents().find("head").text();
alert(sett_wped_head);
but it returns body{color:red;}
. my goal to get value is
<style>body{color:red;}</style>
<link type="text/css" rel="stylesheet" href="some link">
is it possible?
Upvotes: 5
Views: 3098
Reputation: 115202
You need to use html()
for getting html content inside
var sett_wped_head = jQuery('iframe').contents().find("head").html();
// ------^------
alert(sett_wped_head);
Upvotes: 6