jQuery problem with selector -


i have strange problem. using jquery intercept particular tag click.

i have:

<a class="question">lorem ipsum</a> <a class="question_selected">lorem ipsum</a> <a class="question">lorem ipsum</a> <a class="question">lorem ipsum</a> 

and jquery is:

$("a.question").click(function(){.....}); 

it should intercept <a> click class="question" intercepting whenever click <a class="question_selected">.

what can problem?

edit: changing classes on click. tag click should become "question_selected" , other should "question". here jquery: $('a.question_selected').removeclass('question_selected').addclass('question'); $(this).addclass('question_selected').removeclass('question');

remove underscore class name. perhaps there's bug in jquery regarding that.

otherwise, doesn't directly answer question, suggestions:

first of all, instead of swapping class, i'd use 2 classes:

<a class="question">lorem ipsum</a> <a class="question selected">lorem ipsum</a> 

then, in jquery, i'd cache questions:

$questions = $('a.question'); 

and jquery can be:

$questions.click(function(){     $questions.filter('.selected').removeclass('selected');     $(this).addclass('selected'); }) 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -