猿问

input框的赋值问题

html

<button id="plusCount" class="plus-f" type="button" onclick="buyNumber('inputNum','add')">

                        <i class="layui-icon layui-icon-add-1"></i>

                    </button>

                    <input id="inputNum" type="text" value="1" autocomplete="off">

                    <button id="minusCount" class="minus-f" type="button" onclick="buyNumber('inputNum','del')">

                        <div class="minus"></div>

                    </button>

js:

function buyNumber(inputNum,flag){

            var inputNum = document.getElementById("inputNum");

            if(flag == "del") {

                inputNum.value = parseInt(inputNum.value) - 1;

                console.log(inputNum.value);

            }else{

                    inputNum.value = parseInt(inputNum.value) + 1;

                    console.log(inputNum.value);

            }

        }

后台可以看到value值的变化,但是在input框里没有变化。



兔奶奶次萝波
浏览 725回答 3
3回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答