Unfortunately, I need to click the <div> itself. I've tried every
which way to avoid it, but the UI I'm creating requires it. 8|

On Sep 10, 11:09 am, ryanstreet <[EMAIL PROTECTED]>
wrote:
> perhaps, if you are looking to have an element shown for an indefinite
> period of time, perhaps just using show() and hide() are more up your
> alley.
>
> So instead of toggle for a div, use show and hide elements.  That way,
> you don't have to write super functions and whatnot.  That is the joy
> of Jquery! Since you are clicking inside the div, you are clicking on
> the div itself, you are triggering the event.  Try using a separate
> link or separate div to show the main information.
>
> <a onClick="$('#mainContent').toggle();">Show Me!</a>
>
> <div id="mainContent" style="display:none;>
>      Click here for more info
>      <a onClick="$('#info').show();">do something</a>
> </div>
> <div id="info" style="display:none;>blah blah blah...</div>
>
> <script>
>
> Hope this helps!!
>
> On Sep 10, 10:07 am, jtibbetts <[EMAIL PROTECTED]> wrote:
>
> > Unfortunately, adding "return false" to the link inside the "toggle"
> > <div> doesn't stop the toggling. The "return false" just cancels the
> > default behavior of the link (i.e. the href), but I need to cancel the
> > default behavior of the parent "toggle" <div>. :\
>
> > On Sep 9, 6:45 pm, FrenchiINLA <[EMAIL PROTECTED]> wrote:
>
> > > to make id simple i add an 'notoggle' id to your link you can use the
> > > following code:
> > >         $('#toggle').click(function() { alert('toggle'); });
> > >         $('#notoggle').click(function() { alert('No Toggle'); return
> > > false; }); or if you don't want use id for the link $('#toggle a')
> > > instead of $('#notoggle').
> > > <div id="toggle">
> > >       Click here for more info
> > >       <a id="notoggle">do something</a>
> > >  </div>
>
> > > On Sep 9, 12:41 pm, jtibbetts <[EMAIL PROTECTED]> wrote:
>
> > > > How do you stop .toggle() from toggling an object when a link (or any
> > > > object) inside the object is clicked.
>
> > > > Here's a quick contrived example:
>
> > > > <div id="toggle">
> > > >      Click here for more info
> > > >      <a onClick="DoSomething();">do something</a>
> > > > </div>
> > > > <div id="info">blah blah blah...</div>
>
> > > > <script>
> > > > $("#toggle").toggle(
> > > >      function () {
> > > >           $("#info").show();
> > > >      },
> > > >      function () {
> > > >           $("#info").hide();
> > > >      }
> > > > );
> > > > </script>
>
> > > > Clicking on the "toggle" <div> toggles the "info" <div>. If the "do
> > > > something" link is clicked, the "toggle" <div> will toggle *and*
> > > > DoSomething() will be called. I want to be able to click the "do
> > > > something" link and only have DoSomething() trigger but not cause the
> > > > <div> to toggle. Is this possible?
>
> > > > (Forgive the code if it's wrong, but I just whipped it up on the fly)

Reply via email to