How would you change the title of a button?

How would you change the title of a button?

tcardinaltcardinal Posts: 31Questions: 9Answers: 0

I have a button and on the click event want to change the title. I have tried a variety of ways and the current definition is as follows, the key line being $(this).attr("title", "Show xxxx");

     {
          "text":"<i class=\"fa fa-list fa-2x fa-fw\" aria-hidden=\"true\"></i>",
          "titleAttr":"Show all files",
          "action":function ( e, dt, node, config ) { 
              if (usingAltSrc) {
                var uSrc = cSrc;
                usingAltSrc = false;
                this.text(altSrcIcon);
                $("#filedesc").html("All live files or still awaiting a decision");
                $(this).attr("title", "Show all files");
         }
        else {
             var uSrc = altSrc;
             usingAltSrc = true;
             this.text(cSrcIcon);
             $("#filedesc").html("All files");
             $(this).attr("title", "Show filtered list");
         };
        $("#filelist").DataTable().ajax.url(uSrc).load();
     } 

any ideas?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 9,822Questions: 0Answers: 1,629

    This example from this thread should help - it's showing just that.

    Colin

  • tcardinaltcardinal Posts: 31Questions: 9Answers: 0

    Thanks Colin, but it is the title attribute (titleAttr) that I am trying to update. Changing the text on the button works fine (this.text), but I can't get it to change the title attribute (which pops up on Mouse Over).

  • colincolin Posts: 9,822Questions: 0Answers: 1,629
    Answer ✓

    Ah, you can use button().node() for that, see here.

    Colin

Sign In or Register to comment.