CodesJava

Easy learning with example program codes

Backbone.JS View SetElement()


The Backbone.JS View SetElement() method is used to specify the existing DOM element to a different DOM element.

Syntax:

View.SetElement (element)   

Parameters:
element: This parameter is used to specify the element to be changed.

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="1">  
Enter any text: <input type="text"/>  
</div>  
<div id="2"></div>  
<script type="text/javascript">  
var X = Backbone.View.extend({  
events: {  
'change': 'Hello'  
},  
initialize: function() {  
this.setElement($('#1'));     
},  
Hello: function() {  
document.write('HELLO WORLD!!');  
}  });  
var Y = new X;  
</script>  
</body>  
</html>

Output:



Example




Enter any text:



Please follow and like us:


Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki