Good afternoon, dear colleagues!

There is a small task, there is a javascript object

var obj = { up:function(id,type) { //Необходимо вернуть объект, вызвавший эту функцию } down:function(id,type) { //Тоже самое } } 

And there are several objects on the page causing these actions, let's say:

 <!--В начале страницы--> <div class="rating"> <i class="icon-plus" onClick="obj.up(1,'page')"></i> <b>0</b> <i class="icon-minus" onClick="obj.down(2,'page')"></i> </div> <!--В конце страницы--> <div class="rating"> <i class="icon-plus" onClick="obj.up(1,'page')"></i> <b>0</b> <i class="icon-minus" onClick="obj.down(2,'page')"></i> </div> 

Well, accordingly, I need to get an object in the function that launched that function so that I could then change the value of <b> 0 </ b> in the block .rating in which the event occurred.

Do not tell me how best to implement?

  • 2
    obj.down(2,'page',this); either hang up the handler using js instead of onclick="" this.nextSibling will be your element b - zb '26
  • I wanted to do without the third parameter this, but apparently not destiny. and hang events on the objects house, hmm ... you can try) - chuikoff
  • Maybe I have not yet woken up and did not understand something, but is it really impossible ? PS I did not wake up yet)) I did not take into account the transmitted values. But you can do it this way . - Deonis

0