Question

I have this JQuery function that will not execute if the item in question is a button or input, and now I want to add DropDownList to this condition.

How do I do this?

Query's if-statement I tried using selector as my best guess

if (!$(e.target).is('button') && !$(e.target).is('input') && !$(e.target).is('selector'))

my View

<td class="col-lg-3">
    <span class="item-display">
           <span style="font-size: 17px">
                  @Html.DisplayFor(modelItem => item.Location.Location1)
           </span>
     </span>
     <span class="item-field">
         @Html.DropDownList("locationID", item.Location.Location1)
     </span>
</td>

Thank you!

Was it helpful?

Solution

Just view the HTML and it will give it away. The @Html.DropDownList() creates a <select> object.

The following should work:

!$(e.target).is('select')

By the way, your jquery can be dramatically simplified (untested):

if (!$(e.target).is('button, input, select'))

OTHER TIPS

The HTML element for a drop down is select so just change your statement to this:

if (!$(e.target).is('button') && !$(e.target).is('input') && !$(e.target).is('select'))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top