jQuery函数被错误地调用。

时间:2014-08-03 05:13:03

标签: javascript jquery html

我的代码中有一个滑块。当我点击它时点击它,它会发出一条消息"叫做#34;。但问题是它只是在点击滑块上的方块时提醒消息但是我想在点击滑块上的任何位置后提醒消息。

这是我的代码。

<html>
<head>
<link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
      <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
      <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
$(document).ready(function(){
$(function () {

         $("#slider-1").slider({
             range: true,
             min: 0,
             max: 500,
             values: [0, 0],
             slide: function (event, ui) {
                 $("#priceA").val("$" + ui.values[0] + " - $" + ui.values[1]);
             },
             stop: function () {
                 getValues();
             }
         });


     });

$("#slider-1").click(function(){
alert('Called');
});      

});          
</script>
</head>
<p>
    <label for="priceA">Price rangeA:</label>
    <input type="text" id="priceA" style="border:0; color:#067ab4; font-weight:bold;">
</p>
<div id="slider-1" class="myClass"></div><br><br>
</html>

1 个答案:

答案 0 :(得分:2)

您是否希望即使在滑块上随机点击也应该提醒消息::然后尝试:

stop: function () {
  alert('called');
  getValues();
}

这里是DEMO LINK,请查看。

相关问题