On Feb 8, 4:08 pm, cbmtrx <[EMAIL PROTECTED]> wrote:
> OK, I'll need to look into this click event. If it's worth rewriting
> (because the original degrades poorly) then I'll probably do it this
> way.
>
> Was hoping jquery would simplify!! :/

For your sample code, you don't need that javascript link, you can
just define 'click(toggle)' event for <a /> element and then trigger
it in <input /> elememt's 'click' event. using 'class' instead of 'id'
and letting jQuery help you find corresponding DIVs can make your code
simpler (you can extend this into more than 2 groups easily):

<!--ONE-->
<a href="#">Open 1</a>

<div class="olddiv">
  Default page content
</div>

<div class="newdiv">
  <form>
    New page content
    <input type="button" value="Close" />
  </form>
</div>

<!--TWO-->
<a href="#">Open 2</a>

<div class="olddiv">
  Default page content
</div>

<div class="newdiv">
  <form>
    New page content
    <input type="button" value="Close" />
  </form>
</div>

<script type="text/javascript">
 $('a').toggle(function() {
     $(this).next('div.olddiv').hide()
            .next('div.newdiv').show();
 }, function() {
     $(this).next('div.olddiv').show()
            .next('div.newdiv').hide();
 });
 $('[EMAIL PROTECTED]"Close"]').click(function() {
     $(this).parents('div.newdiv').prevAll('a:first').click();
 });
</script>

Regards,
lihao(XC)

Reply via email to