• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

What does this jquery functiondo?

I am new to jQuery and need a line by line (or function by function) description of this code:

        function setButton($button) {
           $button.children().andSelf().attr('disabled', 'disabled');
           $("img", $button).attr("src", function (index, attr) { return attr && attr.replace("~/images/myImage.png", "ajax-loader16.gif"); });
        }

Thanks!
0
newbieweb
Asked:
newbieweb
  • 2
1 Solution
 
Gurvinder Pal SinghCommented:
//method definition, parameter is a element object
function setButton($button) {
           //disables himself and all its children
           $button.children().andSelf().attr('disabled', 'disabled');
           // image element inside this element is given new src by computing the value at run time
           // it takes the original src attr value as the input and replace it with ajax loader image
           $("img", $button).attr("src", function (index, attr) { return attr && attr.replace("~/images/myImage.png", "ajax-loader16.gif"); });
        }
0
 
newbiewebAuthor Commented:
//disables himself and all its children
how can a button have children?

 // image element inside this element is given new src by computing the value at run time
// it takes the original src attr value as the input and replace it with ajax loader image
Why doesn't this function always display the "ajax-loader16.gif" image? I don't see how it adjusts for whether it needs to display the "ajax-loader16.gif" image?


0
 
newbiewebAuthor Commented:
Thanks.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now