JQuery slideToggle replace image src

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2010-05-27T19:11:39Z Indexed on 2010/05/27 19:11 UTC
Read the original article Hit count: 238

Filed under:
|
|
|
|

Hi, This function is called when an up/down arrow is clicked to slide hidden div. If the div is hidden, the arrow points down and changes to up when the div is shown. If the div is shown, the arrow points up to hide div and changes to down when the div is closed. I just wanted to know if there was a more efficient way of doing this or if this is the correct way. Thanks.

  function showInfo(info_id) {
    var img_id = '#arrow_'+info_id;
    var div = '#info_'+appointment_id;
    $(div).slideToggle('normal',function() {
        if ($(this).is(':visible')) {
            $(img_id).attr('src',$(img_id).attr('src').replace('_down','_up'));
        }
        else {
            $(img_id).attr('src',$(img_id).attr('src').replace('_up','_down'));
        }
    });}

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about replace