On 5/8/07, Equand <[EMAIL PROTECTED]> wrote:


$("img", "#preview").attr("src").replace(/\?.*$/g)
what's wrong with this?
i try to strip of all text after ? and the ?....


replace() returns the modified string instead of directly modifying the
original one (any method that changes a string in some way does this too),
so the correct code would be:

$("img", "#preview").each(function() {
   this.src = this.src.replace(/\?.*$/g);
});

or more "jQuery-ish":

$("img", "#preview").attr("src", function() {return this.src.replace
(/\?.*$/g);});

see http://docs.jquery.com/DOM/Attributes#attr.28_key.2C_fn_.29 for more
info on exactly how I did that.

--
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]
http://aheimlich.freepgs.com

Reply via email to