user3885720
user3885720

Reputation: 79

jQuery function being called incorrectly.

I have a slider in my code. when I click I click on it, it alerts a message "called". But the problem here is it is alerting the message only when the square on the slider is clicked but I want to alert a message after clicking anywhere on the slider.

Here is my code.

<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>

Upvotes: 0

Views: 56

Answers (1)

nsthethunderbolt
nsthethunderbolt

Reputation: 2097

Do you want that even clicking randomly on the slider should alert a message:: then try this:

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

and here is DEMO LINK , check it out.

Upvotes: 2

Related Questions