hankknight
asked on
JavaScript/jQuery: Find class attribute of body from a string
How can I get the class attribute of the body tag from a string?
This does NOT work:
This does NOT work:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('e r=\'<!h 2 f "-//g//4 j 1.0 B//d" "5://6.3.8/i/9/4/9-k.l"><2 m="5://6.3.8/n/o" q:c="s"><a><b>t</b><u v="w" x="y z A" /><7 C="D/E"></7> </a><F G="H I"><p>J K L</M></2>\';',49,49,'||html|w3|DTD|http|www|script|org|xhtml1|head|title|lang|EN|var|PUBLIC|W3C|DOCTYPE|TR|XHTML|transitional|dtd|xmlns|1999|xhtml||xml|data|en|Title|meta|name|description|content|HR|Home|Description|Transitional|type|text|javascript|body|class|hello|world|Invalid|HTML|HERE|div'.split('|'),0,{}))
alert(data);
alert( $(data).find('body').attr('class') );
</script>
</head>
<body>
</body>
</html>
ASKER
sedgwick, your code is useless to me. I need to get this from a STRING not from the DOM. Please test it with the code I posted. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window