Description

(>=1.3.1) Gets the previous element. It is possible to filter on an attribute. Return false if the element was not found

Usage

Parameters

  • attr {String} optional

    (optional) Attribute name

  • val {Object} optional

    (optional) Attribute value

Returns

CanvasEngine.Element|Boolean

Example

In method ready

var el1 = this.createElement(),
    el2 = this.createElement(),
    el3 = this.createElement(),
    el4 = this.createElement();

el1.attr("foo", "bar");
el2.attr("foo", "yoo");

stage.append(el1, el2, el3, el4);

stage.last().prev();                // returns el3 element
stage.last().prev("foo");           // returns el2 element
stage.last().prev("foo", "bar");    // returns el1 element
stage.last().prev("foo", "hi");     // returns false

Discussion