Simple inline DOM manipulation library
Include the js file:
<script src="foron.js"></script>
Initialize whenever you want:
Foron.init();
then
<div>Some Text</div>
<span f-click="prev().set('New Content')">Click Me</span>
and run the html and click on the span.
Event | Description |
---|---|
f-click | click |
f-rclick | right click |
f-init | on foron init |
f-bind | on change |
Function | Description |
---|---|
id('element_id') | select element with id |
next() | select next element |
prev() | select previous element |
parent() | select parent element |
trigger('event') | trigger event |
set('content') | set text |
append('current') | append text |
addClass('class') | adds a class |
removeClass('class') | removes a class |
toggleClass('class') | toggles the provided class |
enable(bool) | enables/disables the selected element |
toggleHide(with css) | toggles hide(with css otherwise with hidden) |
bind(optional selector,property) | set property(text default) of currently selected element with value |
wait(millisecond) | delay the next operation in chain(bt execution will continue) |
reset() | reset selection [and queue] |
me() | reset selection |
log(attr, logger function) | logs attribute(default is value) |
attr('attribute name') | attribute** |
val() | value** |
otherwise() | the else part of the current condition |
but() | resets the current condition chain |
Function | Description |
---|---|
eq(value) | equals |
ne(value) | not equals |
gt(value) | greater than |
gte(value) | greater than or equals |
lte(value) | less than or equals |
between(min,max) | greater than min and less than max |
and(value) | and operation |
or(value) | or operation |
prop(property) | gets the property |
op(method,param1,param2,..) | invokes method on current value with params |
then() | sets the current value as condition and sets the domnode chain |
num() | converts to number(0 if not a number) |
id('name1').val().eq('xyz').then().toggleHide()
- Koushik Seal - thekoushik