Backbone.js Tutorial - 8 - (Views) Creating New HTML Elements (ok)

Thêm một thẻ trong một thẻ cha :)

C:\Users\Administrator\Desktop\gulp\app.js

var theView = Backbone.View.extend({
	tagName: 'p',
	className: 'classspan',
	id: 'idspan',
	initialize: function() {
		this.$el.html("Hello World");
	}
});
jQuery(document).ready(function($) {
	var page = new theView();
	$('#div1').html(page.$el);
});

C:\Users\Administrator\Desktop\gulp\app.js

var theView = Backbone.View.extend({
	tagName: 'span',
	className: 'classspan',
	id: 'idspan',
	initialize: function() {
		console.log(this.el);
		console.log(this.$el);
	}
});
jQuery(document).ready(function($) {
	var page = new theView();
});

C:\Users\Administrator\Desktop\gulp\app.js

var theView = Backbone.View.extend({
	tagName: 'span',
	className: 'classspan',
	id: 'idspan',
	initialize: function() {

	}
});
jQuery(document).ready(function($) {
	var page = new theView();
	$('#div1').html(page.$el);
});

Last updated

Navigation

Lionel

@Copyright 2023