[英]LightSwitch HTML change format format with Button_execute event
有沒有辦法格式化按鈕,例如在按下按鈕時將其更改為文本或背景顏色,從而使其成為一種切換開關?
為了使事情變得更復雜,我談論的是添加到表中(在表的每一行上)的按鈕,我只想更改單擊的按鈕的格式,而不是更改表中的所有按鈕。 如果可能的話,更改所選行的格式也是一個選項。
如果這是_postRender,則可以使用element和contentItem,但如何在ButtonClick_execute中使用它們?
您可以使用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 {顏色:綠色;}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.