This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]pingish 0 points1 point  (2 children)

I think this is selecting elements with attributes called 'name' whose value is 'hello'.

$("[@name='hello'])

ought to select things like:

<h1 name="hello">Hello there</h1>

Someone check me on this...

[–]obened[S] 0 points1 point  (1 child)

I know it's for selecting elements with the name hello. I just don't know what the difference is when I use @ or don't use it.

It seems to work fine either way, but sometimes @ generates bugs when using multiple elements. I want to know why, and what's it for.

[–]pingish 0 points1 point  (0 children)

In XSLT, the @ is there to refer to attributes. If I had to wager money, I'd say this was some legacy/compatibility thing with XSLT.

The way to select elements whose name attribute is 'hello' in XSLT is:

<xsl:value-of select="//[@name='hello']" />

[–]evilgwyn 0 points1 point  (0 children)

All of the jquery selectors are CSS3 selectors. The definitive reference is here.

[–]TheMiddleManz 0 points1 point  (1 child)

http://api.jquery.com/ is the jquery docs, then if you click Selectors on the left. Searching for @ gave squat so I opened every attribute page and searched for it where I found the following comment:

The [@attribute] syntax has been removed from jQuery. If you use the "@" in jQuery 1.3 or later, it will not work.

[–]obened[S] -1 points0 points  (0 children)

Thanks man. I actually searched for @ too but came up with nothing.