gpt4 book ai didi

javascript - jQuery 函数被错误调用。

转载 作者:行者123 更新时间:2023-12-02 17:07:41 25 4
gpt4 key购买 nike

我的代码中有一个 slider 。当我点击它时,它会提醒一条消息“叫”。但这里的问题是,仅当单击 slider 上的方 block 时才发出警报消息,但我想在单击 slider 上的任意位置后发出警报消息。

这是我的代码。

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

最佳答案

您是否希望即使随机单击 slider 也会发出警报消息::然后尝试以下操作:

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

这里是DEMO LINK ,检查一下。

关于javascript - jQuery 函数被错误调用。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25101849/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com