5

AJAX body class html

 3 years ago
source link: https://www.codesd.com/item/ajax-body-class-html.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

AJAX body class html

advertisements

I have this AJAX function

        type: "GET",
            url: url,
            cache: false,
            dataType: 'html',
            success: function(data){

            },
            error: function(){ },
            complete: function(){ }
        });

ofcourse that "data" represent entire document with <html> but I only want to get class of body element from this data variable.

Does anyone know how to do that? To get class of body element from retrieved data?

Thank you very much for every advice.


You can do this in plain JavaScript:

success: function(data){
    var parser = new DOMParser();
    doc = parser.parseFromString(data, "text/html");
    // Your class(es)
    var docClass = doc.body.getAttribute('class');
    // Garbage collection, you don't need this anymore.
    parser = doc = null;
}

Related Articles

Extract all classes from the body element of the AJAX-ed page and replace the body classes on the current page

I am in the process of AJAX-ing a WordPress theme with a persistent music player. Wordpress uses dynamic classes on the <body> tag. The basic structure is as follows: <html> <head> </head> <body class="unique-class-1 unique

How to overlay a new div on the entire body of HTML using Jquery?

I am having similar issue as posted here.. During Ajax request, I am trying to put background image of loading icon and greyed background, somehow the greyed background does not extend to the bottom of the page. As I scroll, it goes away. I tried rem

Define the body class with the jquery cookie plugin

I'm trying to create a "highcontrast" style switcher with jQuery Cookie plugin I've been busting my head for couple of hours now, read a lot of questions on stackoverflow.com, but I didn't solve my problem. Idea is to toggle class "highcont

How to display ajax response to HTML in Code Lighter

I need to display the json data that i receive from ajax request to html In alert i am getting the json data Here is my view <?php for ($i=0; $i<5; $i++){?> <a href="#" class='testing' data-index="<?= $i;?>" >testl

jQuery works to change body class in an index

I have a list of N unique body classes, they all have a corresponding big background image on them. I'm trying to build what essentially boils down to a standard slider but instead of shifting through the li's in a target class, I'm switching body cl

Add the body class to the node in Drupal 8

I am experimenting with Drupal 8. I've created a local sandbox site and created a custom theme and a custom front page using Twig (page--front.html.twig). I want to add some custom CSS that just targets the front page and I am used to targeting the b

Drupal 8 - adding body class based on a taxonomy term or other

Building a site in Drupal 8, using classy subtheme. Run into a puzzling theming issue - adding body class to html.html.twig based on a taxonomy term on that node. Themers use this to customize page display, in my case using it to define a few section

Using Jade, how can I declare a body class in an extended model?

Using the Jade template engine, I want the ability to optionally declare classes to body tags, in templates that extends another. layout.jade !!! 5 html(lang='en') head block title meta(charset='utf-8') link(rel='stylesheet', href='/stylesheets/style

Change the value of the placeholder according to the body class

I have a small page where I swicth from one language to another by changing the body class: https://jsfiddle.net/3ddo465n/2/ <div class="en container"> <p lang="en"> ... </p> <p lang="ru"> ... </p&g

How to call ajax in my HTML form

i have this ajax function: $.ajax({ url: "http://localhost:56472/WebSite2/Service.asmx/Area", method:"post", data: { l: "custom value", b: "custom value", } success: function (data) { console.log(data.length); var x

Add Woocommerce product type to body class class

I am trying to add Woocommerce product types to the Wordpress body tag class array thats called in header.php with body_class(); I have the following function in functions.php but it is not adding the class. If I remove the conditional and just have

Css: in the body class, the simple text becomes dark but do the links also get it?

in my css i have a problem: body.transparent {background-color: transparent;color:#ffffff;text-shadow: 0 -1px #000, 1px 0 #000, 0 1px #000, -1px 0 #000;} The text-shadow was supposed to affect only simple, non-formated text. But it not just affects t

Unable to set body class with Template.helpers

To add dynamic class for body tag i used: <body class="{{bodyClass}}"><!-- this remains uncompiled --> {{bodyClass}} <!-- this renders to "blue" --> </body> and helper code: Template.body.helpers({ bodyClass: fu

Can we use it like this & lt; Body class = & ldquo; All & rdquo; & Lt;! - [if IE 7] & gt; Class = & ldquo; Ie & rdquo; & Lt; [Endif] - & gt; & Gt;

Can we use like this <body class="all" <!--[if IE 7]>class="ie"<![endif]--> >? I want to keep all CSS in one file.You could use: <body class="all"> <!--[if ie]> <div class="ieOnly"&g
HashFlare

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK