gpt4 book ai didi

jquery - 警告 jquery slider 与 ui.value 的问题

转载 作者:行者123 更新时间:2023-12-01 04:07:28 25 4
gpt4 key购买 nike

当我移动第一个 slider 并按下第二个按钮时,它显示第一个 slider 的值,反之亦然,但我只想要第二个 slider 的值

html

<h1>HTML Slider Test</h1>
<div class="slider"></div>
<p>Your slider has a value of <span class="slider-value"></span></p>
<input type="button" class="ab" value="send">
<div class="slider"></div>
<p>Your slider has a value of <span class="slider-value"></span></p>
<input type="button" class="ab" value="send">

jquery

$(".slider").slider(
{
value:1,
min: 0,
max: 100,
step: 1,
slide: function( event, ui ) {
a=ui.value;
$(ui.handle).closest(".slider").next( "p").find(".slider-value").html( ui.value );
}
}
);

$( ".slider-value").html( $('.slider').slider('value') );

$(".ab").click(function(){
alert(a);
});

http://jsfiddle.net/5TTm4/1937/

最佳答案

单击按钮时从第二个 slider 获取值

HTML

 <h1>HTML Slider Test</h1>
<div>
<div class="slider"></div>

<p>Your slider has a value of <span class="slider-value"></span></p>
<input type="button" class="ab" value="send" />
</div>


<div>
<div class="slider"></div>
<p>Your slider has a value of <span class="slider-value"></span></p>
<input type="button" class="ab" value="send" />
</div>

Jquery

 $(".ab").click(function(){
a= $(this).closest('div').find('.slider').slider("option", "value");
alert(a);
});

<强> Demo

关于jquery - 警告 jquery slider 与 ui.value 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25680447/

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