Bug Tracker

Opened 12 years ago

Closed 12 years ago

#7480 closed bug (invalid)

Has attribute selector not working for <a> elements

Reported by: [email protected] 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="http://www.w3.org/1999/xhtml">


	<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.

Change History (3)

comment:1 Changed 12 years ago by jitter

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.

comment:2 Changed 12 years ago by jitter

Keywords: needsreview added

comment:3 Changed 12 years ago by dmethvin

Keywords: needsreview removed
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.

Note: See TracTickets for help on using tickets.