是否有办法格式化按钮,例如在按下按钮时更改文字或背景颜色以使其成为一种切换开关?
为了使这更复杂,我在谈论我添加到表格中的按钮(在桌子的每一行),我只想改变点击的按钮的格式并不是全部表中的按钮。如果可能的话,更改所选行的格式也是一种选择。
如果这是一个_postRender我可以使用element和contentItem但是如何使用ButtonClick_execute中的那些?
答案 0 :(得分:0)
您可以使用jquery css方法。 您必须在html中链接Jquery库
$('#ID_Of_BUTTON').click(function(){ //This code will be executed when button is clicked
$('#ID_OF_BUTTON').css('Css Attribute','value'); //Put css Attribute as color
$("#ID_OF_BUTTON").attr('value', 'NAME HERE'); //This Changes the Name or Value
});`
您还可以在css中创建两种不同的样式,并切换类。
$('#ID_OF_Button').click(function(){
$('#ID_OF_Button').toggleClass('Clicked');
$('#ID_OF_BUTTON').toggle(
function(){
$(this).val('on'); //Changes Value to on
},
function(){
$(this).val('off'); //Changes Value to off
}
);
});
Css:.clicked {color:green;}