Thanks a ton. Although I had another way to do it like:

if($(imgID).attr("src").indexOf("expand") >= 0)

but using the way you mentioned is more accurate and specific to
JQuery. Thanks once again.

On Sep 26, 2:27 pm, "Richard D. Worth" <[EMAIL PROTECTED]> wrote:
> contains is a pseudo-selector, but not a method. So you can use it like
> this:
>
> html before:
> <p>the quick brown</p>
> <p>fox jumped over</p>
> <p>the lazy dog</p>
>
> script:
> $("p:contains('the')").remove();
>
> html after:
> <p>fox jumped over</p>
>
> That doesn't really help in the scenario you've posed because contains
> searches the text of the element 
> (seehttp://docs.jquery.com/Selectors/contains#text). What you want is the
> attributeContains attribute selector. See:
>
> http://docs.jquery.com/Selectors
>
> Under "Attribute Filters" there is
>
> [attribute*=value]
> Matches elements that have the specified attribute and it contains a certain
> value.http://docs.jquery.com/Selectors/attributeContains#attributevalue
>
> So in your example that would be
>
> if ( $("#myimg[src*='expand']").length )
>   // do something
> else
>   // do something else
>
> - Richard
>
> Richard D. Worthhttp://rdworth.org/
>
> On Thu, Sep 25, 2008 at 11:21 PM, JQueryProgrammer <[EMAIL PROTECTED]>wrote:
>
>
>
> > I have an image tag as
> > <img id="myimg" src="images/expand.jpg" />
> > I am trying as
> > if($("#myimg").attr("src").contains("expand"))
> >    // do something
> > else
> >    //do something else
> > but it gives an error "Object doesn't support this property of
> > method". Please help.

Reply via email to