开发者

Problem with toggling

I have searched this forum but i can't get any solutions to work, im trying to toggle a textarea visibility but all textareas are being toggled at once. im fairly new with jquery but here is my code

jQuery(document).ready(function() { jQuery(".note").hide(); jQuery(".note_button").click(function() { jQuery(".note").fadeToggle("slow", "linear"); }); });

to wo开发者_开发百科rk with this html:

<table>

    <tbody>

        <tr>
            <td colspan='2' class='product-name'>
            </td>
                <td>

             </td>
    <td></td>
       <td class="cart-widget-remove">   

             </td>


      </td>
        </tr>
        <tr>
        <td colspan="6">
            <form id="desc" action="" method="post" class="adjustform">
             <div class="note">
                <textarea name="" onfocus="this.value='';">Your optional note to the kitchen</textarea>
                <input class="" type="button" value="Apply changes" />
                <input class="" type="button" value="Cancel" />

             </div>
            </form> 


If this pattern shows up multiple times on your page

<form id="desc" action="" method="post" class="adjustform">
  <div class="note">
    <textarea name="" onfocus="this.value='';">Your optional note to the kitchen</textarea>
    <input class="" type="button" value="Apply changes" />
    <input class="" type="button" value="Cancel" />
 </div>
</form> 

Then your selector jQuery('.note') will select all .note divs. You'll need to give them unique IDs to select individual divs for hiding/showing or use the id already on the form.

jQuery('#desc .note').fadeToggle(...);


It looks like we only have part of the code, but I'll give it a shot...

The jQuery is toggling all areas because your selector isn't targeting the one you want to toggle specifically. Presumably you have other textareas that also are inside divs with the class "note". If each one of these divs had a unique class (say "note-1", "note-2", etc.) then you could select the specific textarea you wanted to toggle.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜