I was wondering whether there is any way to trigger the 'click' event of the EditorFor when I press on (or around) the glyphicon icon?
Here's the code:
<div class="col-md-10">
@Html.EditorFor(model => model.FullName, new { htmlAttributes = new { @class = "form-control" } })
<span style="font-size:1.5em;" id="f1" class="glyphicon glyphicon-question-sign form-control-feedback"></span>
@Html.ValidationMessageFor(model => model.FullName, "", new { @class = "text-danger" })
</div>
Thanks
First give an id to the EditorFor:
@Html.EditorFor(model => model.FullName, new { htmlAttributes = new { @class = "form-control", @id = "e1" } })
<span style="font-size:1.5em;" id="f1" class="glyphicon glyphicon-question-sign form-control-feedback"></span>
And then use jQuery as follows:
$("#f1").bind("click", (function () {
$("#e1").trigger("click");
}));