I think you can do this a little differently to achieve the effect you're looking for. One thing you should be aware of is that IDs and classes must start with a letter. We won't have to access those numbers in the script anyway.

$(document).ready(function() {
  $('div.add_image_content').hide();

  $('input.add_image').bind('click', function() {
    $(this).next().toggle();
  });
});

Hope that works for you.



--Karl
____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Jul 12, 2008, at 2:42 PM, jt wrote:


I have a form with the following (there are about 20 of these; you can
assume that the id value goes up to 706):

<input id="686" class="add_image" type="button" value="add image"/>
add image 2

and beneath it would like to have a form element that is normally
hidden:
<div class="add_image_content 686" >hello in add_image_content</div>

Basically, I'd like to be able to access the e.targed.id and then use
it in a selector to select div's that have 'add_image_content' and the
associated id value.

My javascript is:
$(document).ready(function(){
     $('.add_image_content').hide();

     $('.add_image').bind('click',function(e){

     //alert(e.target.id);
     var $val=e.target.id;
     $(div:contains($val)).show();
     //didn't work
     //$('.add_image_content' + e.target.id).show();
     //$(e.target.id).show();
});
});

thanks for any help,

jt

Reply via email to