querySelector()
Searches the DOM for a matching element.
Syntax
var element = behavior.querySelector([node, ] selector);
If you only supply one argument then that argument is the selector
and the document
is used as the context node for the search.
Example
var mybehavior = jsb.behavior.extend({ onchange: function(element) { if (!this.validate(element)) { var flag = this.querySelector(element, "+ .flag"); this.addClass(flag, "invalid"); // indicate an error } } });
Notes
This method provides a cross-browser, safe way to perform the W3C equivalent method. Please note that some browsers do not support this method so you should always use the jsb method.