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

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.

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;
?>
```