如何在选择列表框中的项目时触发动画

How to trigger an animation when an item in listbox is selected

本文关键字:项目 动画 选择 列表      更新时间:2023-09-26

我得到了一个由两个选项组成的列表框:

<table width="auto" height="auto" style="position:relative; top:100px;">
  <tr>
    <td><select name="payment_selection"></td>
    <td>
       <option id="sel_cash" value="">Cash - pay in station</option>
       <option id="sel_account" value="">Customer account</option>
    </td>
    </select>
  </tr>
</table>

当客户选择Cash-pay-instation时,这应该出现在下面:

<td>Total</td>
<td><?php //code ?></td> 

当客户选择客户帐户时,这应该通过JavaScript显示在下面:

<td>Your remaining balance is</td>
<td><?php //code ?></td>

你能给我推荐一些代码吗?我只知道onclick功能的按钮但不是列表框并且具有选择。希望题目对我的问题是正确的。

<table width="auto" height="auto" style="position:relative; top:100px;">
      <tr>
        <td><select onchange="somefunction();" name="payment_selection"></td>
        <td>
           <option id="sel_cash" value="">Cash - pay in station</option>
           <option id="sel_account" value="">Customer account</option>
        </td>
        </select>
      </tr>
    </table>
<script>
function somefunction(){
alert("value changed!");
}
</scrip>

我想你知道这个会发生什么

$( '#payment_selection' ).bind({
'change': function( event ) {
alert( $( this ).val() );
}
});