javascript - Mootools Click Event Problem -
This peace of code works for the first click. But then it is not able to get a new ID with the next click. The idea behind this is to show a piece of a form and click on a button to hide it first and the second part shows what any ideas are doing wrong? I think there is something with "this" in it but I think it should also get the ID from the second link. $ ('Hidden'); $ ('hide'); $ ('page'); $ ('page' Slide ('hide'); $ ('page_5') Slide ('Hide') var TogglePrint = 'Toggle_', BoxPrint = 'Page_', EmptyPrint = ''; var link = $ ('submit_box 'GetElements' ('A'); links.addEvent ('click', function (e) {estop (); var id = $ (this.get ('id'). Replace (TogglePrint, emptyprint)) var Id_new = parseInt ($ (this) .get ('id'). Replace (togglePrefix $ (Id_old) .set ('slide'),, {duration: 'long', transit: 'linear'}); $ (id_old ) .slide ('o ut'); $ (apple) ('In') .slide;});});
html follows this method:
gt; & Lt; Span & gt; Camille & lt; / Span & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; Input type = "radio" name = "fridge 1" value = "katus" /> gt; & Lt; Span & gt; Cactus & lt; / Span & gt; & Lt; / Div & gt; & Lt; Div & gt; & Lt; Input type = "radio" name = "frase1" value = "crocus" gt gt; & Lt; Span & gt; Crocus & lt; / Span & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div id = "submit_box" & gt; & Lt; An id = "toggle_1" class = "frage" & gt; Nächste frage ... & lt; / A & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div id = "gewinn_werbung" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt;
If I understand the example, then you get a bunch of divs with the ID page Gone, page 2 and so on. In each div, there is a div with the id "submit_box" when you type $ ('submit_box'). GetElements ('a')
This will only add events due to the first div because the ID should be unique You can not have more than one element on the page with a unique ID. So to change your example, change the ID to a classname and use $$ ('div.submit_box a').
Comments
Post a Comment