Access CSS values ​​with jQuery while cleaning with node.js

I clear the page using node.js (basically), then jQuerify the result to access the CSS values ​​for some elements. However, for some reason .css ("something") always returns an empty value. For example ..text (), however, works fine. Any hints? Do I need to output a cleaned page first before I can access CSS?

var request = require('request');
var jsdom = require('jsdom');

var req_url = 'URL';

request({uri: req_url}, function(error, response, html){
    if(!error && response.statusCode == 200){
        var window = jsdom.jsdom(html).createWindow();
        jsdom.jQueryify(window, 'http://code.jquery.com/jquery-1.4.2.min.js', function() {
            var bg = window.$("#ID").css("color");
            console.log(bg);
        });
    }
});
+3
source share
1 answer

I think .css () will only return the inline css of this element.

Unfortunately, what you are trying to do is hard to get around without an active browser.

PhantomJS - node.js webkit, javascript.

0

All Articles