Jan Koekepan
Jan Koekepan

Reputation: 79

jQuery read title with $.get page

I would like to get the title witch is included in a other page (on same domain).

On the moment, the following code isn't working:

$.get("/example.html", function(html){
    alert($(html).attr('title'));
});

Content of the example.html page is:

<html>
  <head>
    <title>foo</title>
  </head>
  ...
</html>

Upvotes: 1

Views: 28

Answers (1)

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67207

You can use filter() at this context to filter out the title tag,

alert($(html).filter("title").text());

And use .text() to extract its text content.

Upvotes: 1

Related Questions