简体   繁体   中英

Javascript Slider event handles

I am new to this site and I would like to know more how to handle events in slider with jquery-mobile. I've tried basic events like bind,slidestop, etc.. but nothing happens. I just want to get a prompt message when the slider value changes. Bellow is my code for JS and HTML.

JS:

$('#mstrbedroom').on({ 
  start: function(event,ui){ 
    alert("halaka");
  },
  stop: function(event,ui){ 
    alert("agoy");
  }
});

HTML CODE:

<label for="mstrbedroom">Dimmer</label>
<input name="mstrbedroom" id="mstrbedroom" min="0" max="100" value="50" type="range">

You're not binding any events. The on function requires the event parameter which is the first parameter, in this case I believe you want slide . Please read through: http://api.jquery.com/on/ .

Try the following and please go through (pretty much the whole page or at least the events section) http://api.jqueryui.com/slider/#event-slide :

$('#mstrbedroom').slider({
    start: function(event,ui) {
        alert("halaka");
    },
    stop: function(event,ui) {
        alert("agoy");
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM