JQuery OK and Cancel Functions in Modal Textarea -


i working create functional ok , cancel buttons variable number of modal textareas on page.

the html this:

<a href="#00001_modal" class="modal">note</a>          <div id="00001_modal" class="window bgiframe">              <h3>notes print speed:</h3>             <textarea name="00001_notetext" id="00001_realtextarea" class="rltb"></textarea>             <textarea name="00001_tempnotetext" id="00001_temptextarea" class="rte"></textarea>             <a href="#" class="close-modal cancelbtn">cancel</a>             <a href="#" class="close-modal donebtn">done</a>         </div>   

i have modal functions need, populating proving difficult. behavior trying attain before close modal is:

  • "cancel" anchor clears editable (second) textarea
  • "done" anchor takes entry editable textarea , puts real (first) textarea

also, editable textarea should populate contents of real textarea when modal opened.

i've gone down jquery rabbit hole of finding anchors respective parents, having trouble selecting textarea children of said parents.

this: alert(($(this).parent()[0].id)>("textarea"):nth-child[1];

is dumb , doesn't , makes me feel making more complicated needs be.

there has got simple way done, right?

it done closest() function. here example:

$('.cancelbtn').click(function(){     $(this).siblings('.rte').val('');     return false; });  $('.donebtn').click(function(){     $(this).siblings('.rltb').val( $(this).siblings('.rte').val() );     return false; }); 

here sample on jsfiddle.net


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -