javascript image toggling

Posted by Sunil Ramu on Stack Overflow See other posts from Stack Overflow or by Sunil Ramu
Published on 2010-06-15T02:01:20Z Indexed on 2010/06/15 2:02 UTC
Read the original article Hit count: 259

Filed under:
|

I have a tree view which has a folder icon by default and once clicked it has to be changed to a checkbox icon. And further on clicking the checkbox icon should display a folder icon.

Sample Code,

Server side : c# htmlSb.AppendFormat("

  • {0}
  • ", emptyContent);

    JS code

    var Test= new Object(); Test.Controls=new Object(); Test.Controls.TreeView = new Object();

    **Test.Controls.TreeView.SelectNode = function (TreeId, nodeLabel) { $("#" + TreeId + " li span, ul li span").css("background-color", "transparent"); nodeLabel.style.backgroundColor = "white";

        nodeLabel.style.background = "url(../images/selected.gif)  0 0 no-repeat";
    

    }**

    The other Image :

    if (nodeLabel.style.background = "url(../images/folderclosed.gif) 0 0 no-repeat")

    I need to toggle between "selected.gif" and "folderclosed.gif" images. If one is clicked the other should display. and vice versa.

    Please help.

    © Stack Overflow or respective owner

    Related posts about .NET

    Related posts about JavaScript