0

When I send the AJAX request, if it success it returning a values. For example

$('#content').load(url, function (info) {

})

In this code info is returning the HTML page source.

<!DOCTYPE html>
<html lang="en-US" dir="ltr" autopagermatchedrules="1">
<head>
<body class="single single-post postid-1 single-format-standard logged-in admin-bar single-author singular two-column right-sidebar" linkifying="true">
</html>

How can I get the body class name.

1 Answer 1

5

This should do it.

$('#content').load(url, function (info) {
    var classes = $(info).find('body').attr('class');
});
Sign up to request clarification or add additional context in comments.

3 Comments

Ok.. for me its not working... pls check the url link
@Mifas I think it has to do with all the extra elements. Try writing it to an iframe and then searching or if you're desperate use a regular expression.
@alex can u please tell me how can i do this in regular expression

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.