Search code examples
javascripthtmlcssmodel-view-controller

How can I make a span clickable?


I have this code:

    <span class="glyphicon glyphicon-search"></span>
    @Html.TextBox("text", Model.Search.text, new {placeholder = Html.T("Поиск"), @class = "form-control"})

and as a result this one:

search panel

It's work fine if user type some text and press Enter. Search work fine. But the "search" button not works. It's just stay and not clickable. How do I make "search" button clickable without losing appearance?


Solution

  • Add the onclick event. (https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onclick)

    <span class="glyphicon glyphicon-search" onclick="myFunction()"></span>
    @Html.TextBox("text", Model.Search.text, new {placeholder = Html.T("Поиск"), @class = "form-control"}
    

    myfunction can be the function that triggers the submit on your input.