How to change a button's text

3 posts, 1 answers
  1. Andreas
    Andreas avatar
    4 posts
    Member since:
    Nov 2011

    Posted 26 Jun 2015 Link to this post

     I'm simply too stupid for that. Why does the following not work?
    Debugging the lines there the function is called without any error.

     

       <button class="k-button" id="myTextButton" type="button">Enable</button>

    ....

     

     <script>

      $(document).ready(function () {

        $("#myTextButton").click(function () {
                        ("#myTextButton").enable(true);
                        ("#myTextButton").value = "value text";
                        ("#myTextButton").text = "text text";
                        ("#myTextButton").html = "html text";
                        ("#myTextButton").innerHTML = "innerHTML text";
                    });

    </script>

  2. Answer
    Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 26 Jun 2015 Link to this post

    Hello Andreas,

    Please refer to the jQuery API documentation section (text method).

    Regards,
    Petyo
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Kendo UI is VS 2017 Ready
  4. Kyle Smith
    Kyle Smith avatar
    42 posts
    Member since:
    Feb 2012

    Posted 20 Nov 2015 in reply to Petyo Link to this post

    Hi Petyo,

    FYI, using the jquery text method clears out the icon set via the spriteCssClass configuration option. To work around  this, I wrapped the button text in a span and updated the span text directly.

    Button Markup
    <button id="#buttonID" type="button"><span class="button-label">View Batch (0)</span></button>
     
    Script for updating label
    $('#buttonID > .button-label').text('NEW LABEL');

Back to Top