-2

试图在点击事件中获取对象。我在这里做错了什么?this.section 是每个按钮的索引。

  this.ebutton        = jQuery('.episode_button');
  this.button         = this.ebutton.eq(this.section);
  this.listtext       = 'testbutton';

  this.button.parobj  = this;
  this.button.bind('click', function() {

    alert(this.parobj.listtext());

   });

如何在按钮事件中获取属性 listtext?

4

2 回答 2

0

试过了

$("#"+this.id).parent()

或者

$(<selector>).parent()

http://api.jquery.com/parent/

于 2012-10-08T13:59:04.780 回答
0
     var epi = {};

     /*Startpage*/
     epi.start = {
         epilist:            [],

         init: function () {
             this.ebutton                = jQuery('.episode_button');
             this.episodelist.prototype  = this;

             this.epilist.push(new this.episodelist(0));
         },


         episodelist: function (index) {
             this.name           = 'test'
             this.button         = this.ebutton.eq(index);
             this.button.parobj  = this;
             this.button.bind('click', function() {this.parobj.episodelistshow();});
         },

         episodelistshow: function () {

             // This will not alert correctly!
             // Should alert test
              alert(this.name);            

         }
     }​
于 2012-10-09T05:57:57.500 回答