Jquery slider disable click on slider

I’ve got the following problem:

I have a Jquery slider and I want to disable the click on the slider.
I only want to change the slider when I click and drag the pointer.
Standard you can also click everywhere on the slider and the pointer will go to that point. That I don’t want. ;).

Can someone help me?

This is the code:


<!DOCTYPE html>
<html>
<head>
	<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
	<style type="text/css">
		div.demo { padding: 10px !important; };
	</style>
	<script type="text/javascript">
	$(function() {
		$("#slider-range-max").slider({
			range: "max",
			min: 1,
			max: 10,
			value: 2,
			slide: function(event, ui) {
				$("#amount").val(ui.value);
			}
		});
		$("#amount").val($("#slider-range-max").slider("value"));
	});
	</script>
</head>
<body>

<div class="demo">
    <p>
        <label for="amount">Minimum number of bedrooms:</label>
        <input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" />
    </p>
    <div id="slider-range-max"></div>
</div>

</body>
</html>

What you could try is first unbind click events attached to your element, then bind new functionality onto it, something like:
$(‘.myButton’).unbind(‘click’);
$(‘.myButton’).bind(‘click’, function() {

});

Thanks for your solution TommiChi, but it seems that this solution doesn’t work. Or can you give the script code how you should change it?
Anyone got another solution?

Hi Mark,

I am facing the issue. I want to disable the click event on jquery slider. Have you got any solution yet? Please help me.

Thanks,
Ads

How were you adding the jQuery to the page, were you adding it using jQuery’s document [B].ready/B method?