Backbone.JS View $(jQuery)

The Backbone.JS View $(jQuery) method is used as a selector. It contains $ function and runs queries within the view’s element.

Syntax:

View.$(selector)  

Parameters:
selector: This parameter is used to specify the type of selector such as, id or class.

Example:

<!DOCTYPE html>  
<html>
<head>  
<title>Example</title>  
<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js" 
type="text/javascript"></script>  
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js" 
type="text/javascript"></script>  
</head>  
<body>  
<div id="A">  
<button id="button" data-test="">Just a Click</button>  
</div>  
<span id="B"></span>  
<script type="text/javascript">  
var B = $('#C');  
var info = function(data) {  
document.write(data);  
};  
var X = Backbone.View.extend({  
events: {  
'click [data-test]' : 'data1',  
'click *[data-test]': 'data2',  
},  
el: $('#A'),  
data1: function () {  
info('Hello');  
},  
data2: function () {  
info(' World!!');  
}  });  
var Y = new X();  
</script>  
</body>  
</html>

Output:



Example