The jQuery object has no 'src' property, use attr() to get the
element's attributes, and you can only pass a single function to click
():

$('#my_header').click(function(){
   var $img = $(this).find('img');
   var src = $img.attr('src');
   var newsrc = /up\.gif$/.test(src) ? src.replace('up','down') :
src.replace('down','up');
   $img.attr('src',newsrc);
});

- ricardo

On Nov 15, 12:15 am, bob <[EMAIL PROTECTED]> wrote:
> Hi,
> I am trying to create a toggler that I would like to work
> as follows:
> User clicks on #my_header and source of the image gets replaced.
> I tried the following but it did not work.
>
> <div title="show/hide" id="my_header" >
>         <img src="images/arrow_down.gif"/>
>         <span>Some title here</span>
> </div>
>
> $(function() {
>         $('#my_header').click(
>             function() {
>                                 $('#my_header img').src = $('#my_header 
> img').src.replace( /_down
> \.gif$/, '_up.gif' );
>             },
>             function() {
>                                 $('#my_header img').src = $('#my_header 
> img').src.replace( /_up
> \.gif$/, '_down.gif' );
>             }
>         );
>
> });

Reply via email to