0
$(document).ready( function() {
 $('#date').bind("change",function(){
  var x=$("#date").val();
  alert(x);
 });
});

对应的html代码:

 <form id="form1">
  <tr>
    <td class="tr_tab"><a class="qtn_data">I am:</td><td class="tr_tab"> </a> 
      <input type="radio value="male" name="gender" /><a class="qtn_data">Male</a>&nbsp
      <input type="radio" value="female" name="gender"/>
      <a class="qtn_data">Female</a>

    </td>
  </tr>
  <tr>
    <td colspan="2">
      <hr/ id="hr3">
    </td>
  </tr>
  <tr>
     <td class="tr_tab"><a class="qtn_data">Date of birth:</td><td class="tr_tab"> </a> 
      <input type="text" name="date" placeholder="Date" MaxLength="2" id="date" />&nbsp
      <input type="text" placeholder="Month" MaxLength="2" id="month" />&nbsp
      <input type="text" placeholder="Year" id="year" MaxLength="4" />&nbsp</td>
  </tr>
  <tr>
    <td></td>
    <td><span style="float:left;"><a class="qtn_data1">ex: 02/05/1992</a></span>

    </td>
  </tr>
  <tr>
    <td colspan="2">
      <hr/ id="hr3">
    </td>
  </tr>
  <tr>
    <td><a class="qtn_data">I am from:</a>

    </td>
    <td>
  <input type="text" id="place" placeholder="Town" />
    </td>
  </tr>
  <tr>
    <td></td>
    <td>
      <input type="text" id="place" placeholder="State" />
    </td>
  </tr>
  <tr>
    <td></td>
    <td>
      <input type="text" id="place" placeholder="Country" />
    </td>
  </tr>
</form>

更改文本框中的文本后Opera,当我移动到另一个窗口时显示警报,但在..中没有效果Firefoxid="date"Chrome

4

2 回答 2

1

有不正确的 HTML

改变

  <tr>
     <td class="tr_tab"><a class="qtn_data">Date of birth:</td><td class="tr_tab"> </a> 
      <input type="text" name="date" placeholder="Date" MaxLength="2" id="date" />&nbsp
      <input type="text" placeholder="Month" MaxLength="2" id="month" />&nbsp
      <input type="text" placeholder="Year" id="year" MaxLength="4" />&nbsp</td>
  </tr>

  <tr>
     <td class="tr_tab"><a class="qtn_data">Date of birth: </a> </td>
     <td class="tr_tab">
      <input type="text" name="date" placeholder="Date" MaxLength="2" id="date" />&nbsp
      <input type="text" placeholder="Month" MaxLength="2" id="month" />&nbsp
      <input type="text" placeholder="Year" id="year" MaxLength="4" />&nbsp
     </td>
  </tr>

在这里你已经关闭了</td>之前关闭的</a>

<td class="tr_tab"><a class="qtn_data">Date of birth:</td><td class="tr_tab"> </a> 

其他地方也有HTML错误,请检查并改正

于 2013-01-16T06:22:46.767 回答
0

试试这个

在此处了解有关绑定change事件的更多信息...

http://api.jquery.com/change/

前任:-

$(document).ready( function()
    $('#date').click(function() {
      $('#date').change();
    });

    $('#date').change(function() {
       var x=$("#date").val();
       alert(x);
    });
});
于 2013-01-16T06:16:39.337 回答