How to change a button's text

4 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>




      $(document).ready(function () {

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


  2. Answer
    Petyo avatar
    2444 posts

    Posted 26 Jun 2015 Link to this post

    Hello Andreas,

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

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. 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');

  4. David
    David avatar
    3 posts
    Member since:
    Aug 2017

    Posted 12 Feb in reply to Kyle Smith Link to this post

    Smart and function solution. Thanks!
Back to Top