tags:

views:

287

answers:

3

i have some links in my page

< a class="Qlink" rel="20;5" href="javascript:void(0);">5</a>
< a class="Qlink" rel="21;6" href="javascript:void(0);">6</a>
< a class="Qlink" rel="22;7" href="javascript:void(0);">7</a>

i do some ajax call and get the first number on the rel attribute(exp. 20)

how do i can change the class of link (the first in my exp.)

+3  A: 
$("a[rel^='20;']").addClass('foo');

See also: attributeStartsWith

Kobi
A: 

If you mean that you want to change the class attribute of your links:

$('a.Qlink').attr('class','your_new_class');

Edit: Based on the other answers, this one is better :

$('a[rel^=20]').attr('class','your_new_class');
Soufiane Hassou
+1  A: 

A combination of Kobi and Soufiane's answers will do what the OP is asking:

$("a[rel^=20]").attr('class', 'your_new_class');

He asked to change the class, after all.

jeerose
Tnx, i needed the attributeStartsWith.
eyalb
[attribute^=value] IS attributeStartsWith...
jeerose