get()

The same as getAttribute() except:

Syntax

behavior.get(element, propertyName);

Example

var number = jsb.behavior.extend({
  max: 100,

  onchange: function(element) {
    var max = this.get(element, "max");
    
    if (element.value > max) {
      alert("Please enter a number less than " + max);
    }
  }
});

The above example needs to be understood in the context of some HTML content:

<input type="text" value="50">
<input type="text" value="50" max="200">

For the first <input> element the value of number.get(element, "max") is 100 (the default value). For the second element the value is 200 (defined on the element).

Notes

HTML5 allows the creation of custom data attributes with the prefix "data-". It is suggested that you use this notation to store data associated with the element.

See Also