Giter Site home page Giter Site logo

css() method about phpquery HOT 7 OPEN

macskas avatar macskas commented on June 12, 2024
css() method

from phpquery.

Comments (7)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
This ticket covers only .css() method:
http://docs.jquery.com/CSS/css#properties

Original comment by [email protected] on 23 Jun 2009 at 2:04

  • Changed title: css() method

from phpquery.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
i love this package, but it is missing this useful addition.. specifically I'm 
looking to show/hide something and could use this to do that. I can use the 
attr() method to set the css but that wipes out all other set css.. 

Original comment by [email protected] on 11 Sep 2010 at 11:31

from phpquery.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
I just searched for the same and ended up here. 

Original comment by [email protected] on 15 Sep 2010 at 9:23

from phpquery.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
Is there any progress on this issue?

Otherwise, I might go ahead and dig into this myself...

Original comment by [email protected] on 21 Feb 2011 at 8:56

from phpquery.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
I'm looking at moving the QUAIL Accessibility library to be built on PHPquery, 
but I did do a big CSS parser, you can find that at:
http://code.google.com/p/quail-lib/source/browse/trunk/quail/common/css.php

Original comment by [email protected] on 25 Mar 2011 at 4:21

from phpquery.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
Nice! Now we only need to stick it into PHPQuery. If the project owner would 
only respond... I'm much in favour of posting the code on Github and continue 
going forward with the project. Does the license have any restrictions with 
regard to that?

Original comment by [email protected] on 28 Mar 2011 at 7:53

from phpquery.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
Hi! I made my decision css.
Replace in pnpQuery.php this code:
    public function css() {
        // TODO
        return $this;
    }
to this:
    public function css($param, $value = '') {
        $style = $this->parseCSS($this->attr('style'));
        if(empty($value))
            return $style[$param];
        $style[$param] = $value;
        $this->attr('style', $this->saveCss($style));
        return $this;
    }

    function parseCSS($style) {
        $style = trim($style);
        if(substr($style, -1) != ';') $style .= ';';
        preg_match_all("|(.*):(.*);|U", $style, $out, PREG_PATTERN_ORDER);

        $style = array();
        for($i=0; $i<count($out[1]); $i++) {
            $attr = trim($out[1][$i]);
            $value = trim($out[2][$i]);

            $style[$attr] = $value;
        }

        return $style;
    }
    function saveCss($parsed) {
        foreach($parsed as $key => $value)
            $style .= $key.': '.$value.'; ';
        return $style;
    }

Attention! For attribute "style" only!

use:
pq('div#foo').css('background');
pq('a#bar').css('color');

Original comment by [email protected] on 14 Nov 2014 at 12:35

from phpquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.