Dan
Dan

Reputation: 1244

Jquery mobile slider events not firing

I want to alter the proportions of a DIV using a jquery slider (on a mobile device). The code is pretty simple and works on a JS Fiddle ( http://jsfiddle.net/gsjBC/1/ ) but not on a normal html page for some reason. Can anyone help me identify why not?

Here is the html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Testing</title>


    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js">      </script>
</head><body>

<div data-role="fieldcontain"><input type="range" name="slider" id="slider" value="60" min="0" max="100" /></div>

<script>
$("#slider").change(function() { 
sliderValue =    $(this).val();$("#proportion").width(sliderValue*3);
$("#proportion").height(300-sliderValue*3);});
</script>

<div id="proportion" style="border:1px solid #ccc; width:150px; height:150px;" /></div>
</body>
</html>

Upvotes: 0

Views: 1733

Answers (1)

hyankov
hyankov

Reputation: 4120

Put:

$("#slider").change(function() {

In

$(document).ready(function() {
// here
});

Upvotes: 1

Related Questions