HTML set checkbox as readonly

Sometimes we don't want to make some form fields non-editable to users, like Product ID, Order Created Date, Post Author, etc.

For HTML text input and textarea controls, we can add "readonly" attribute to disallow users to modify their value, but this attribute will not work for checkbox control. So how should we disable the checkbox (or set it as readonly)? The "disabled" attribute will do the job

(It works for both radio box and checkbox)

 

You will see following checkbox and radio button is disabled:


Fabric.js set text color

Fabric.js is a powerful javascript canvas library which wraps html5 canvas operation, and introduces objects (text, shape, path, etc.) to developer.

There is a common method set() for object, it can be used to set property of an object. But if you want to change text color, text.set('color', '#0f0') will not work.

To set color of text, we need modify the fill attribute or use setColor() method (only available for text object)

Or