Edit 1 (Sorry for the confusion)
$(this).hide();
will work for this particular id. But i think i coundnt put my query clearly. Although I got the answer, I have edited it now for future reference.
I have elements like this
<img src='images/star-transparent.png' id='star_transparent-1' width='30' height='30' class='star_transparent' />
<img src='images/star-transparent.png' id='star_transparent-2' width='30' height='30' class='star_transparent' />
<img src='images/star-blue.png' id='star_blue-1' width='30' height='30' class='star_blue' />
<img src='images/star-blue.png' id='star_blue-2' width='30' height='30' class='star_blue' />
and so on.. What I want is trigger onclick event to the class, and hide the transparent image which was clicked and show the colored one. My current jquery is -
$('.star_transparent').click(function() {
var star_id = $(this).attr('id');
$(this).hide();
//how to write the 'id' with 'class' in the following line
$('.star_blue').show();
});
In one similar question here, the proposed answer said to use something like -
$("#star_transparent-1.star_transparent");
or
$("#star_transparent-1 .star_transparent");
But, in my case star_transparent-1
or star_transparent-2
i.e. ID is itself a variable which is derived from class.click function. So how should I write that?
Also, in the above mentioned proposed answer, it was said that #star_transparent-1.star_transparent
and #star_transparent-1 .star_transparent
are two different things. it was quoted as -
The space is the descendant selector, i.e. A B means "Match all elements that match B which are a descendant of elements matching A". AB means "select all element that match A and B".
But, i am sorry to say, I didnt understand it. If anybody can explain it more easily, that would be a great help.
thanks. regards
Dr. Atul Tiwari