Comments (7)
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.
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.
I just searched for the same and ended up here.
Original comment by [email protected]
on 15 Sep 2010 at 9:23
from phpquery.
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.
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.
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.
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)
- Unable to install using pear HOT 7
- pear repo packages.xml seems broken
- Wrong parsed HTML from HTML cleared by Tidy
- default: added to all HTML tags via Clone & PrependTo
- typo in line 517
- when program is utf-8,but remote page is gbk , the wrong has occur
- A PHP Error was encountered
- How to print the whole array of result without using foreach
- Notice (8): Undefined variable: hltml [phpQuery\DOMDocumentWrapper.php, line 389]
- GPL ?
- DOMDocument::importNode(): Cannot import: Node Type Not Supported
- Nested elements in script tag / create elements with jQuery
- Case-sensitive tag selectors HOT 3
- phpquery-onefile.php line 517
- Using multiple selectors return element list in wrong order
- Patch for /branches/dev/demo.php
- elements with dots "." in their id cannot be selected
- Getting Started Page
- How to use http-proxy for getBrowser & ajax requests? HOT 1
- your api docs have been hacked
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpquery.