输入字段中的Glyphicons

时间:2018-04-16 05:30:55

标签: javascript c# html asp.net-mvc

如何将glyphicons放入输入字段?我尝试了几种解决方案,但没有正常工作,"确定"的字形。并且"删除"无论如何都出现在输入之外。 HTML:

<div class="modal-body">
            @using (Html.BeginForm("SetOneTimeDeliveryAddress", "Orders", FormMethod.Post, new { Name = "OneTimeDelivery", id = "OneTimeDelivery" }))
            {

                <div class="form-group">
                    <div>
                    <label>Nazwa:</label>
                <div>@Html.TextBoxFor(Model => Model.NazwaPelna, new { Name = "NazwaPelna", id = "Nazwa", @class = "form-control" })</div>
                </div>
                    </div>

JavaScript的:

},
        highlight: function (element) {
            $(element).closest('.form-group').removeClass('has-success').addClass('has-error');
            $(element).closest('.form-group').find('[class^="glyphicon"]').remove();
            $(element).closest('.form-group > div > div').append('<span class="glyphicon glyphicon-remove form-control-feedback" ' + 'aria-hidden = "true"' + ' id="statushigh">');
        },
        unhighlight: function (element) {
            $(element).closest('.form-group').removeClass('has-error').addClass('has-success');
            $(element).closest('.form-group').find('[class^="glyphicon"]').remove();
            $(element).closest('.form-group > div > div').append('<span class="glyphicon glyphicon-ok form-control-feedback"' + ' aria-hidden="true" ' + 'id="statussun">');
        },
        success: function (element) {
            $(element).closest('.form-group').addClass('valid').closest('.control-group').removeClass('error').addClass('success');
        },

其效果:

enter image description here

1 个答案:

答案 0 :(得分:0)

enter image description here

<form>
<div class="input-group">
  <span class="input-group-addon"><i class="glyphicon glyphicon-user"></i></span>
  <input id="email" type="text" class="form-control" name="email" placeholder="Email">
</div>