IDs are unique identifiers, you can use classes instead (both can't
start with a number) or use an attribute selector:

<div id="some1"></div>
<div id="some2"></div>

<div id="thing1"></div>
<div id="thing2"></div>

$('div').click(function(){
    var idtext = this.id.match(/\D*/); //exclude numbers
    $("[id*="+ idtext +"]").show();
});

If you click #some1, it will show all DIVs whose ID's have 'some' in
it.

It's easier with classes, but you have to be sure there is only one
class:


<div class="class1"></div>
<div class="class1"></div>

<div class="class2"></div>
<div class="class2"></div>

$('div').click(function(){
    $('.'+this.className).show();
});

On Nov 20, 10:37 am, jrutter <[EMAIL PROTECTED]> wrote:
>  I was able to use an alert to show the id of what was clicked! But Im
> trying to show/hide elements based on what is clicked.
>
> So for example, if you click link 1 (id="1") - all div's with id="1"
> will show, but div's with id="2" will be hidden. I can get everything
> to show, but not just id="1".
>
> Here is my code, what am I doing wrong?
>
> $(event.target.id)show(); $(event.target.id:not).hide();
>
> Here is the full code:
>
>         //grab values from attributes assigned in xsl
>         var qtID = $(this).attr("id");
>
>         // make id to show comment (#23453-3djis-im37vk9-fkifhf7)
>         var ccID = '#' + qtID;
>
>         //show only comments of matching ccID that were clicked
>         $("#item-comments-listing").show();
>         $(event.target.id)show();
>         $(event.target.id:not).hide();
>
> Any ideas?

Reply via email to