Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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