.resp - OtagJS/Otag GitHub Wiki

.resp( {Property:Response} Object )

.resp( Property String , Response Function )


You can define responsive property to an Element

.resp method allows you to define function to Element which you are able to access old and new value of the property.

You can access to Element via this; old value of the Property'via this.Property, new assigned value will be the first arguement of the function you define.

let Num='Num'
	.prop({value:5})
	.resp('value',function(newValue){
		console.log('Change:',newValue-this.value);
	})
Num.value=15; // logs: Change: 10

Caution:

If there is no change when set, your function won't be called.