【问题标题】:How to remove selector from Html.TextBoxFor?如何从 Html.TextBoxFor 中删除选择器?
【发布时间】:2017-09-05 09:20:04
【问题描述】:

我对 Html.TextBoxFor 有一点问题。我只需要删除选择器。

@Html.TextBoxFor(m => m.StartFund.Funds, new { id = "startFundsTextBox", @class = "k-textbox", @style = "width:20%; display:inline-block", @type = "number", @min = "0" })

有什么线索吗?

【问题讨论】:

    标签: jquery html asp.net .net razor


    【解决方案1】:

    使用css,您可以从输入类型编号中删除微调器。

    input[type=number]::-webkit-inner-spin-button, 
    input[type=number]::-webkit-outer-spin-button { 
      -webkit-appearance: none; 
      margin: 0; 
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <input type='number' />

    【讨论】:

    • 就是这样!非常感谢你:)
    • 很高兴帮助。投票并接受答案。快乐编码。 :)
    【解决方案2】:

    删除@type="number" 属性(因此也删除@min,因为它现在无关紧要):

    @Html.TextBoxFor(m => m.StartFund.Funds, new { id = "startFundsTextBox", @class = "k-textbox", @style = "width:20%; display:inline-block" })
    

    这使它成为一个普通的文本框,而不是一个数字输入。

    【讨论】:

    • 谢谢你的回答,但我想留在@type="number" 并且只删除选择器。
    猜你喜欢
    • 2014-04-03
    • 1970-01-01
    • 2016-01-06
    • 2017-05-03
    • 1970-01-01
    • 2023-04-01
    • 2012-02-04
    • 2013-07-13
    • 2019-04-24
    相关资源
    最近更新 更多