Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mathsgod/p-query
Using jquery like method to parse html by using php
https://github.com/mathsgod/p-query
dom html php php-library
Last synced: 29 days ago
JSON representation
Using jquery like method to parse html by using php
- Host: GitHub
- URL: https://github.com/mathsgod/p-query
- Owner: mathsgod
- License: mit
- Created: 2019-01-09T08:15:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-05-16T03:24:29.000Z (9 months ago)
- Last Synced: 2024-12-06T17:34:10.375Z (2 months ago)
- Topics: dom, html, php, php-library
- Language: PHP
- Homepage:
- Size: 253 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![LICENSE](https://img.shields.io/github/license/mathsgod/p-query)
![PHP Composer](https://github.com/mathsgod/p-query/workflows/PHP%20Composer/badge.svg)
## Introduction
PQuery is a PHP library used to control html string by using jQuery liked method.## Example
```php
require_once("vendor/autoload.php");$p = p('
');
Hello$p->find(".hello")->text("abc");
echo $p; /*output
abc
*/
```## PQuery supported method
- size
- last
- first
- html
- prepend
- prependTo
- appendTo
- append
- attr
- after
- before
- css
- closest
- data
- addClass
- text
- contents
- children
- find
- remove
- removeAtt
- removeClass
- replaceWith
- required
- each
- val
- filter
- parent
- warp
- warpInner
- toggleClass
- hasClass
- prev
- next
- index## HTML element style and class
```php
$div = new HTMLDivElement();
$div->classList->add("container");
$div->innerText = "Hello world!";
$div->style->color = "red";echo $div; //
Hello world!
```## Element.append
### Append an element
```php
$div=new HTMLDivElement();
$p=new HTMLParagraphElement();
$div->append($p);echo $div; //
```### Appending text
```php
$div=new HTMLDivElement();
$div->append("Some text");echo $div; //
Some text
```### Appending an element and text
```php
$div=new HTMLDivElement();
$p=new HTMLParagraphElement();
$div->append("Some text",$p);echo $div; //
Some text
```
___
created by Raymond Chong