메신저 백본 .js를 사용하기 시작하고 im은 javascript를 사용하여 간단한 작업을 수행하려고합니다. 이는 div 표시/숨기기입니다. 내가 div를 보여 주지만 나는 그것을 숨길 수 없어, 나는 많은 것을 시도, 어떤 생각? 아니면 더 정교 할 수 있을까요?Div 디스플레이 Backbone.js
// If `this.el` is a string, pass it through `$()`, take the first
// matching element, and re-assign it to `el`. Otherwise, create
// an element from the `id`, `className` and `tagName` properties.
귀하의 코드는 말합니다 :
var Step1View = Backbone.View.extend({
el: $('body'),
events: {
'click #more': 'more',
'click #hide': 'hide',
},
initialize: function(){
_.bindAll(this, 'render', 'more', 'next', 'less');
this.render();
},
render: function(){
var self = this;
$(this.el).append("<a id='more'>Show more</a>");
$(this.el).append("<div id='show' style='display: none'>Div12</div>");
return this;
},
more: function(){
$('#more').text('Hide more');
$('#more').attr('id', '#hide');
$('#show').show();
},
less: function(){
$('#hide').text('Show more');
$('#show').hide();
},
});
건배
감사합니다 !! 그 매력은 매력과 같습니다. – ki0