简体   繁体   English

jQuery-UI .button()导致问题

[英]jQuery-UI .button() causing issues

This is weird and totally unexpected. 这很奇怪,而且完全是意外的。 In my fiddle here , the code does not work if I do, 在我的小提琴中 ,如果我这样做,代码将不起作用,

$("#id").button().click(function(){  
    ...
});

It works if I do, 如果我做得到,

$("#id").click(function(){  
    ...
});

What am I missing? 我想念什么? For reference, I had used this . 作为参考,我使用了this

jsFiddle 的jsfiddle

The problem is when you are trying to get the text of button you are using 问题是当您尝试获取正在使用的按钮的文本时

$(this).html() // it's giving you the html of the button as <span class="ui-button-text">Start</span>

Use 采用

$(this).text()

DEMO DEMO

UPDATE: 更新:

Use 采用

$(this).html("<span class='ui-button-text'>Resume</span>");

Insted of 插入

$(this).html("Resume");

This should be changed for all other button text ie Start, Pause. 对于所有其他按钮文本,即“开始”,“暂停”,应对此进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM