https://github.com/baylorrae/html-class-for-php
This class is designed to work like jQuery when creating and working with html elements.
https://github.com/baylorrae/html-class-for-php
Last synced: 9 months ago
JSON representation
This class is designed to work like jQuery when creating and working with html elements.
- Host: GitHub
- URL: https://github.com/baylorrae/html-class-for-php
- Owner: BaylorRae
- Created: 2010-12-02T01:04:55.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2012-08-28T12:07:14.000Z (almost 14 years ago)
- Last Synced: 2025-04-03T02:51:14.527Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 87.9 KB
- Stars: 14
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This class is designed to work like jQuery when creating and working with html elements. Look at `html.class.php` to see a list of all the available methods.
## A few examples
```php
'text field'
));
// Create a label and input
$label = new html('label', array(
'for' => 'title',
'text' => 'Title'
));
$input = new html('input', array(
'id' => 'title',
'name' => 'title',
'value' => 'My Awesome Site'
));
// Append the label and the input
$div->append($label, $input);
// Or chain the methods
$div->append($label)
->append($input);
// Or append the elements to the div
$label->appendTo($div);
$input->appendTo($div);
// Or clone the div before appending stuff
// This was designed for loops
$tmp_div = $div->_clone()->append($label, $input);
// Put the div on the page,
// and destory the temporary div
echo $tmp_div;
unset($tmp_div);
// Whoops, we forgot to add our heading
$heading = new html('h3', array(
'text' => 'Title Field',
'class' => 'field-heading'
));
// Ah, that's better
$div->prepend($heading);
// Or
$heading->prependTo($div);
// Put the div on the page
echo $div;
?>
```