jquery - Get "class" attr from <body> of $.get() object -


i need class attribute body element of page object retrieved $.get(). in example below, fullcontent set object can't select body element... i'd rather not resort text manipulation this

$.get(url, refreshfullcontent);  var refreshfullcontent = function(response, status, xhr) {     fullcontent = response;        var bodyclass = $(fullcontent).find("body").attr("class");     $("body").attr("class", bodyclass); } 

is there way selectors on object (like i'm trying in example)? if not, best way text? xhr.responsetext contains string of entire response.

if you're getting full html document response, won't consistent behavior between browsers.

some browsers strip away head , body elements.

you try this, no guarantees:

var fullcontent = '<div>' + response + '</div>'; var bodyclass = $(fullcontent).find("body").attr("class"); $("body").attr("class", bodyclass); 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -