I see this (stopping links in their tracks) a lot and it's puzzling,
so i think:

*if you do not want an <a> to actually follow a link, then don't use
an <a>, use a <span> or something instead and use CSS to make it look
like a link to the user*

That will 100% solve all issues with a hyperlink acting like, well, a
hyperlink  :-)

Problem with:
return false;
or
e.preventDefault()

is that if a JavaScript error happened before that, then either of
those lines will never execute to prevent the browser from going
wherever


On Jul 8, 11:09 am, BaBna <thomas.na...@gmail.com> wrote:
> I don't really see where your link is, but if you had .click(function
> (e){e.preventDefault();} to your link, that should disable it.
>
> On Jul 8, 3:54 pm, Jan Limpens <jan.limp...@gmail.com> wrote:
>
> > hi there!
>
> > this plugin extends an input text with 2 links that increase or decrease
> > it's value by 1.
> > unfortunately, due to my dumbness it is not working as I would expect.
>
> > When one clicks at one of the links, the link works normally as a link would
> > (making the request to "").
>
> > Anybody could tell me what I am doing wrong - I am definitely suffering from
> > jquery blindness here...
>
> > (function($) {
> >     jQuery.fn.spinner = function() {
> >         var input = $(this);
> >         var makeButton = function(cssClass, text) {
> >             return $('<a href="" class="' + cssClass + '"><span>' + text +
> > '</span></a>');
> >         };
> >         var spin = function(value) {
> >             var val = parseInt(input.val());
> >             var newValue = isNaN(val)
> >                 ? 0
> >                 : val;
> >             if (newValue + value > -1) {
> >                 newValue += value;
> >             }
> >             input.val(newValue);
> >             return false;
> >         };
> >         input.wrap('<div class="spinner"/>');
> >         var spinDown = makeButton('spinDown', '-');
> >         input.before(spinDown);
> >         spinDown.click(function() {
> >             return spin(-1);
> >         });
> >         var spinUp = makeButton('spinUp', '+');
> >         input.after(spinUp);
> >         spinUp.click(function() {
> >             return spin(1);
> >         });
> >     };
>
> > })(jQuery);
>
> > <input type="text" id="spinMe" name="xxx" value="0"/>
>
> > $('#spinMe').spinner();
>
> > --
> > Jan

Reply via email to