请问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框里没有变化。

1<br data-filtered="filtered">



繁星coding
浏览 368回答 1
1回答

MMMHUHU

把value绑定变量
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5