This is a migrated thread and some comments may be shown as answers.

How to change a button's text

3 Answers 3551 Views
Button
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 26 Jun 2015, 02:24 PM

 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>

3 Answers, 1 is accepted

Sort by
0
Accepted
Petyo
Telerik team
answered on 26 Jun 2015, 03:25 PM

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!
 
0
Kyle Smith
Top achievements
Rank 1
answered on 20 Nov 2015, 09:33 PM

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');

0
David
Top achievements
Rank 1
answered on 12 Feb 2018, 10:28 AM
Smart and function solution. Thanks!
Tags
Button
Asked by
Andreas
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Kyle Smith
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or