Skip to main content

Bug Tracker

Side navigation

#7480 closed bug (invalid)

Opened November 12, 2010 07:07AM UTC

Closed December 23, 2010 05:21PM UTC

Has attribute selector not working for <a> elements

Reported by: Owned by:
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

It works fine for other elements like <p>.

A test case:

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"


<html xmlns="">


	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

	<script type="application/x-javascript" src="./jquery.js"></script>
	<script type="application/x-javascript">
		function go() {
				function() {



<body onload="go();">
<a text="foo"></a>
<p text="bar"></p>



Fails under Firefox 4.0b8pre and Epiphany 2.30.2.

Attachments (0)
Change History (3)

Changed November 12, 2010 09:46AM UTC by jitter comment:1

Not sure if this is a jQuery bug.

AFAIK with HTML 5 a text attribute was introduced for link tags (see spec) which contains the same as the DOM 3 textContent property.

If you try this test case in different browsers you might get very different results.

In many modern browsers you will get two alerts saying "link text" and "bar" instead of "foo" and "bar". In older browser you might get "foo" and "bar" when they have no HTML 5 support yet.

Changed November 16, 2010 01:21AM UTC by jitter comment:2

keywords: → needsreview

Changed December 23, 2010 05:21PM UTC by dmethvin comment:3

keywords: needsreview
resolution: → invalid
status: newclosed

Like jitter said, HTML5 has claimed the text attribute and several browsers already implement it. (IE6/7/8 does not though.) Whenever you're adding custom attributes, it's a good idea to prefix with something like x- or use the data- attribute support sanctified by HTML5.