こんにちは、jquery の初心者です。アニメーションに影響する値をユーザーに入力させようとしています。(上または下に移動)これは私がこれまでに持っているもので、アニメーション化するために値を渡すことができないようです。
html
<select id="selectBox">
<option selected="selected" class="selectBox" value="top">Top </option>
<option class="selectBox" value="bottom">Bottom </option>
</select>
<input type="text" id="value" />
<input id="button" name="button" value="Animate" type="button">
<div class="box"style="height:100px; width:300px; padding: 35px; margin:50px auto;
border:30px solid #000;">
javascript/jquery
< script type = "text/javascript" >
$("#button").click(function() {
var boxType = $('#selectBox').val();
var value = $('#value').val();
console.log(boxType + " " + value);
if (boxType == "top") {
$(".box").stop().animate({
marginTop: $('input').val('changed input value');
}, 1000);
}
if (boxType == "bottom") {
console.log("marginBottom")
$(".box").stop().animate({
marginBottom: $('input').val('changed input value');
}, 1000);
}
}); < /script>
here it is on JSFIDDLE