jQuery is based on "find something -> do something". The "find something" is largely done with selectors (similar to CSS selectors).
you want to find the element with the id="test". that would be $('#test') you want it to do something when that element receives a blur event... $('#test').blur(); <-- that's the event, but it's not doing anything yet. To do something, pass a function to the blur(): $('#test').blur(function() { }); which, when fleshed out a little more, might look like: $('#test').blur(function() { alert('I just got blurred!'); }); While inside these "inner functions", you have a handle on the element that triggered it. It's referred to as $(this). You can also use "plain ol' javascript" and use 'this' (no quotes). Depends on what you're doing with it. $('#test').blur(function() { alert(this.id); alert($(this).attr('id')); // they do the same thing }); Most of this (if not all of it) is covered in the docs. http://docs.jquery.com/ and http://docs.jquery.com/How_jQuery_Works On Tue, Sep 29, 2009 at 1:04 PM, factoringcompare.com < firstfacto...@googlemail.com> wrote: > > Thank you. Could you elaborate on the code so that I can track it > through and understand > > On Sep 29, 8:49 pm, Charlie Griefer <charlie.grie...@gmail.com> wrote: > > $('#test').blur(function() { > > $(this).val($(this).val().replace(/,/g,'')); > > > > }); > > > > You "call" it by telling jQuery to "listen" for the blur() event on the > > element with id="test" (line 1 above). > > > > Your code was correct, but you can replace the $('input#test') with > $(this), > > since $(this) will be a reference to the element that triggered the blur. > > > > On Tue, Sep 29, 2009 at 12:04 PM, factoringcompare.com < > > > > firstfacto...@googlemail.com> wrote: > > > > > Hi, > > > > > New to jQuery. > > > > > I would like to strip out all of the commas in numeric text field > > > called test on blur. New to jQuery. I have had a go at coding would it > > > work? > > > > > $('input#test').val($('input#test').val().replace(/,/g,'')); > > > > > and ....... how do i calll it? > > > > -- > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > wife. And I wish you my kind of success. > -- Charlie Griefer http://charlie.griefer.com/ I have failed as much as I have succeeded. But I love my life. I love my wife. And I wish you my kind of success.