2012-03-01 27 views
1

私は3つのグループで9つのテーブルを表示して非表示にする必要があるテーブルを持っています。 .hideは動作しますが、.showはそうではありません。そしてjqueryは途中で中断しません(私はalert()をコード全体に渡し、alert()を使って表示したり隠そうとしている参加者を表示します。jQuery .hideは動作しますが、表示されません。

012;および値が正しい

ここでは、TRの

<cfloop index="i" from="1" to="9" step="1"> 


     <tbody id="attendeeRow<cfoutput>#i#</cfoutput>"> 
     <tr> 
      <td colspan="2" bgcolor="#693505"> 
      <table width="600" border="0" align="center" cellpadding="4" cellspacing="0"> 
       <tr> 
        <td colspan="2">&nbsp;</td> 
       </tr> 
       <tr> 
        <td width="185" align="right">*Attendee <cfoutput>#i#</cfoutput> Name<br /></td> 
        <td><span id="sprytextfield100<cfoutput>#i#</cfoutput>"> 
        <input name="attendeeName<cfoutput>#i#</cfoutput>" type="text" class="form" size="35" value="" /> 
        <span class="textfieldRequiredMsg"></span></span></td> 
       </tr> 
       <tr> 
        <td align="right">*Attendee <cfoutput>#i#</cfoutput> Title<br /></td> 
        <td><span id="sprytextfield101<cfoutput>#i#</cfoutput>"> 
        <input name="attendeeTitle<cfoutput>#i#</cfoutput>" type="text" class="form" size="35" value="" /> 
        <span class="textfieldRequiredMsg"></span></span></td> 
       </tr> 
       <tr> 
        <td align="right">*Attendee <cfoutput>#i#</cfoutput> Company</td> 
        <td><span id="sprytextfield102<cfoutput>#i#</cfoutput>"> 
        <input name="attendeeCompany<cfoutput>#i#</cfoutput>" type="text" class="form" size="35" value="" /> 
        <span class="textfieldRequiredMsg"></span></span></td> 
       </tr> 
       <tr> 
        <td align="right">*Attendee <cfoutput>#i#</cfoutput> Email</td> 
        <td><span id="sprytextfield103<cfoutput>#i#</cfoutput>"> 
        <input name="attendeeEmail<cfoutput>#i#</cfoutput>" type="text" class="form" size="35" value="" /> 
        <span class="textfieldRequiredMsg"></span><span class="textfieldInvalidFormatMsg"></span></span></td> 
       </tr> 

      </table> 
      </td> 
     </tr> 
     </tbody> 
     </cfloop> 

     <!---- comment: this bottom part is what allows the user to show or hide the elements, I just use the div with an id="counter" to keep track of where I am.---> 
     <tr> 
      <td colspan="2" align="center" bgcolor="#693505" class="form"> 
       <div id="counter" style="visibility:hidden;">0</div> 
       <div id="additional3">[+] Click here to register an additional 3 attendees</div> 
       <div id="subtract3">[+] Click here to remove the last 3 attendees</div> 
      </td> 
     </tr> 

を作成し、ここにjqueryのですスニペットです

+2

FYI、.live()は、お使いのjQueryのバージョンに応じて.delegate()または.on()が使用されなくなりました。 –

+0

そして、違いについての本当に良い記事と新しいスタイルの使い方は次のとおりです。http://www.elijahmanor.com/2012/02/differences-between-jquery-bind-vs-live.html –

+1

それは冷たい融合ですかコード? jQueryは、レンダリングされた出力で動作します。さらに良い方法は、jsFiddleを作ることです。 –

答えて

5

私はあなたが連結を警告するが、DOMの選択のための連結をやっていない

alert("#" + currentRow); 
$("#" + currentRow).show(); 

...

alert("#"+currentRow); 
$("#currentRow").show(); 

がこれであることを意味する...これを前提としています。

+2

それはそれを笑うでしょう。私はこれであまりにも長い時間を過ごした、私は –

2

#subtract3 clickイベントでは、コピー貼り付けエラーが発生しています。

var start = parseInt(start) - parseInt(increment); 

var start = parseInt(end) - parseInt(increment); 

あなたはそれらの要素を交換しないため、また、あなたが代わりに.live("click".click()を使用することができなければなりません。

+0

ありがとう、あなたに感謝youam私は最初の.hideが正しく動作していなかった後に.hideを実現した初期のエラーを修正していただきありがとうございます。 –

関連する問題