标签: button

使用 Jquery 更改按钮单击时的显示属性

我正在尝试加载一个隐藏了一些 div 的页面,看起来像这样:

<input type="button" id="btnStats" values="Stats"/>
<div id="dvStats" style="display:none">Stats</div>
<div id="dvAlbums" style="display:none">Albums</div>
Run Code Online (Sandbox Code Playgroud)

现在 div 只有文本,因为我无法让它们工作。我有一个 JS,它将 dvStats 显示分配给 btnStats 上的单击事件。

$("#btnStats").click($("#dvStats").style.display="block");
Run Code Online (Sandbox Code Playgroud)

还尝试了一些我在搜索有关此问题的较旧问题时看到的方法。

$("#btnStats").click($("#dvStats").css(":display","block"));
Run Code Online (Sandbox Code Playgroud)

我一直无法完成这项工作。也许我错过了什么。

html jquery click button

3
推荐指数
1
解决办法
5万
查看次数

将按钮设置为选中状态并更改样式

这是我的实际按钮样式:

<Style x:Key="CategoryButtonStyle" TargetType="{x:Type Button}">
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Padding" Value="1"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Button}">
                <Grid x:Name="grid">
                    <Path x:Name="TabPath" StrokeThickness="2"
                          Margin="{Binding ElementName=buttonContent, Converter={x:Static c:ContentToMarginConverter.Value}}"
                          Stroke="{StaticResource BorderBrush1}"
                          Fill="{StaticResource TabItemPathBrush}">
                        <Path.Data>
                            <PathGeometry>
                                <PathFigure IsClosed="False" StartPoint="1,0" 
                                            Segments="{Binding ElementName=buttonContent, Converter={x:Static c:ContentToPathConverter.Value}}">
                                </PathFigure>
                            </PathGeometry>
                        </Path.Data>
                        <Path.LayoutTransform>
                            <!-- For some reason  -->
                            <ScaleTransform ScaleY="-1"/>
                        </Path.LayoutTransform>
                    </Path>
                    <Rectangle x:Name="TabItemTopBorder" Height="2" Visibility="Visible"
                               VerticalAlignment="Bottom" Fill="{StaticResource BorderBrush1}"
                               Margin="{Binding ElementName=TabPath, Path=Margin}" />
                    <ContentPresenter x:Name="buttonContent" Margin="10,2,10,2" VerticalAlignment="Center"
                                      TextElement.Foreground="{StaticResource ForegroundBrush}"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter Property="Fill" TargetName="TabPath"> …
Run Code Online (Sandbox Code Playgroud)

c# wpf styles button visualstatemanager

3
推荐指数
1
解决办法
5924
查看次数

android - 如何有一个可点击和可检查的文本视图

我想要以下内容: .) 在单击时更改其背景的文本视图 .) 保持该背景直到再次单击

这一切都归结为“可检查”状态,但我无法弄清楚这究竟是如何工作的。这是我用于背景的xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<!-- pressed -->
<item android:drawable="@drawable/menuselected"
android:state_pressed="true" />

<!-- checked -->
<item android:drawable="@drawable/menuselected"
android:state_checked="true" />

<!-- default -->
<item android:drawable="@drawable/transpixel"/>

</selector>
Run Code Online (Sandbox Code Playgroud)

更新:它现在部分工作。我为我的自定义 Textview采用了http://kmansoft.com/2011/01/11/checkable-image-button/ 中的大部分代码。我实际上是这样做的,我也需要单选按钮的功能。现在我可以检查 Textview,但我无法取消选中它。有人明白为什么会这样吗?

android button textview statelist

3
推荐指数
1
解决办法
4385
查看次数

按钮背景颜色切换

我一直在尝试切换按钮 onclick 的背景颜色属性,但颜色只更改一次并且不会来回切换。下面是代码。

function btnColor(btn, color) {
var property = document.getElementById(btn);
    if (property.style.backgroundColor == "rgb(244,113,33)") {
        property.style.backgroundColor=color;
    }
    else {
        property.style.backgroundColor = "rgb(244,113,33)";
    }
}

<input type="button" id="btnHousing" value="Housing" onclick="toggleLayer('transparent1');btnColor('btnHousing','rgb(255,242,0)');" />
Run Code Online (Sandbox Code Playgroud)

html javascript button background-color

3
推荐指数
1
解决办法
2万
查看次数

使用 HTML 和 JavaScript 添加清除按钮

我不明白为什么这行不通!我的清除按钮什么也不做。这是我的整个表格/计算器。我需要“清除”按钮来清除“英尺”和“米”字段中的文本。

我正在做一个课堂项目。

<body>
<form name="myForm">

<table  border = "0" width = 300px>
<tr>
  <td> 
    Feet:
  </td>
  <td>
    <input type="text" id="feet">
  </td>
</tr>
<tr>
  <td> 
    Meters:
  </td>
  <td>
    <input type="text" id="meters">
</tr>
</table>
</form>
</body>

<p>
<button onClick="calculate()">Convert</button>
<button onClick="clear()">Clear</button>
<p>

<script>

function calculate()
{
  var feet = document.getElementById("feet").value;
  var meters = document.getElementById("meters").value;
  var final;

  if (feet == "" && meters == "")
  {
    alert("Try Again");
    return;
  }
  else if (!(feet == "") && !(meters == ""))
  {
    alert("Try …
Run Code Online (Sandbox Code Playgroud)

html javascript button

3
推荐指数
1
解决办法
3万
查看次数

JFrame - 在 GridLayout 中设置行和列

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;

public class GridLayoutTest {

  public static void main(String[] args) {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JFrame frame = new JFrame("GridLayout Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new GridLayout(3, 2));
    frame.add(new JButton("Button 1"));
    frame.add(new JButton("Button 2"));
    frame.add(new JButton("Button 3"));
    frame.add(new JButton("Button 4"));
    frame.add(new JButton("Button 5"));
    frame.add(new JButton("Button 6"));
    frame.add(new JButton("Button 7"));
    frame.add(new JButton("Button 8"));
    frame.pack();
    frame.setVisible(true);
  }
}
Run Code Online (Sandbox Code Playgroud)

我从这个教程网站得到了代码:http : //www.java2s.com/Tutorial/Java/0240__Swing/HowtoUseGridLayout.htm

该程序在屏幕上显示 8 个按钮。我无法理解按钮的布局安排。注意 row=3,column=2。当我运行程序时,按钮的排列是row=3和column=3....

改变行数实际上会根据给定的行数改变布局,但改变列数并不会改变布局,列数将始终保持为 2。这是为什么呢?可能是屏幕尺寸问题。

java swing button jframe grid-layout

3
推荐指数
1
解决办法
1万
查看次数

如何从操作栏中的按钮打开下拉菜单

我正在为 android 开发一个应用程序,它需要在操作栏中(靠近溢出)有一个按钮,打开一个下拉菜单作为通过单击溢出按钮出现的菜单。有任何想法吗?谢谢

android overflow button drop-down-menu

3
推荐指数
1
解决办法
2123
查看次数

如何用图形路径完全替换WPF按钮的内容?

我已经使用Blend解构了一个标准的WPF按钮,并设法创建一个漂亮的样式按钮,但我无法弄清楚如何使路径填充按钮空间的内部(按钮宽度和高度).我也不确定是否需要指定ContentPresenter,即使它是正确的.我在按钮中间的文本之后(正常),但我的图形路径在它后面.

谁能给我反馈如何完成这个?风格定义为;

    <ControlTemplate x:Key="CurvedButton" TargetType="{x:Type Button}">
        <Grid>
            <Path Fill="#ff951c1f" Data="F1 M 64,16 C 64,24 56,31 48,31 L 15,31 C 7,31 0,24 0,16 C 0,7 7,0 15,0 L 48,0 C 56,0 64,7 64,16 Z" />
            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" Width="Auto" />
        </Grid>
    </ControlTemplate>
Run Code Online (Sandbox Code Playgroud)

这个按钮的用法是;

<StackPanel>
    <Button Template="{StaticResource CurvedButton}" FontFamily="MS Trebuchet" FontSize="40" Width="200" Height="120" Foreground="Black">XXXXXXXXXXX</Button>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)

一切都完成后,它应该看起来像一个弯曲的红色按钮.

提前致谢

瑞安

wpf styles path button contentpresenter

2
推荐指数
1
解决办法
4510
查看次数

如何使用Javascript在asp.net页面中显示是/否按钮

我必须在我的asp.net页面上的某些条件上显示是/否按钮,我使用windows.confirm()来显示,但是windows.confirm显示Ok/Cancel Button,有什么方法可以显示是/否按钮asp.net页面而不是Ok/Cancel使用Javascript?

javascript asp.net button confirmation

2
推荐指数
1
解决办法
8353
查看次数

治愈"后退按钮蓝调"

曾经偶然发现了一个你觉得很有价值的教程,但却没有得到很好的解释?那是我的困境.我知道这个教程有一些价值,但我无法得到它.

  1. 你在哪里称呼每个功能?
  2. 应首先调用哪个函数,然后调用哪个函数,以及哪个函数?
  3. 是否会在应用程序的所有文件中调用所有函数?
  4. 有谁知道一个更好的方法来治愈"Back Button Blues"?

我想知道这是否会引起包括文章作者在内的一些好的对话.我特别感兴趣的部分是控制后退按钮,以防止在按下后退按钮时将重复条目复制到数据库中.基本上,您希望在应用程序中执行脚本期间通过调用以下三个函数来控制后退按钮.从教程中可以清楚地知道调用函数的顺序(参见上面的问题).

使用我的scriptNext函数执行所有前进移动.在当前脚本中调用此方法以激活新脚本.

function scriptNext($script_id)
// proceed forwards to a new script
{
   if (empty($script_id)) {
      trigger_error("script id is not defined", E_USER_ERROR);
   } // if

   // get list of screens used in this session
   $page_stack = $_SESSION['page_stack'];
   if (in_array($script_id, $page_stack)) {
      // remove this item and any following items from the stack array
      do {
         $last = array_pop($page_stack);
      } while ($last != $script_id);
   } // if

   // add next script to end …
Run Code Online (Sandbox Code Playgroud)

php forms button back

2
推荐指数
1
解决办法
1529
查看次数