File tree 3 files changed +627
-352
lines changed
3 files changed +627
-352
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
+
2
3
require ('phpQuery/phpQuery.php ' );
3
4
4
5
// INITIALIZE IT
19
20
// MANIPULATE IT
20
21
$ li = null ;
21
22
// almost everything can be a chain
22
- $ doc ['ul > li ' ]
23
- ->addClass ('my-new-class ' )
24
- ->filter (':last ' )
25
- ->addClass ('last-li ' )
23
+ $ doc ['ul > li ' ]->addClass ('my-new-class ' )->filter (':last ' )->addClass ('last-li ' )
26
24
// save it anywhere in the chain
27
- ->toReference ($ li );
25
+ ->toReference ($ li );
28
26
29
27
// SELECT DOCUMENT
30
28
// pq(); is using selected document as default
36
34
// ITERATE IT
37
35
// all direct LIs from $ul
38
36
foreach ($ ul ['> li ' ] as $ li ) {
39
- // iteration returns PLAIN dom nodes, NOT phpQuery objects
40
- $ tagName = $ li ->tagName ;
41
- $ childNodes = $ li ->childNodes ;
42
- // so you NEED to wrap it within phpQuery, using pq();
43
- pq ($ li )->addClass ('my-second-new-class ' );
37
+ // iteration returns PLAIN dom nodes, NOT phpQuery objects
38
+ $ tagName = $ li ->tagName ;
39
+ $ childNodes = $ li ->childNodes ;
40
+ // so you NEED to wrap it within phpQuery, using pq();
41
+ pq ($ li )->addClass ('my-second-new-class ' );
44
42
}
45
43
46
44
// PRINT OUTPUT
You can’t perform that action at this time.
0 commit comments