1

I am using double click event on a <span></span> to toggle visibility of control in my MVC application.

<span ondblclick="myFunction()">m.Value</span>

where m is my model.

In the above code, span content is m.Value, which can be empty.

When m.Value is empty, ondblclick() event is not fired. Is there any workaround for this.?

Wasif Ali
  • 886
  • 1
  • 13
  • 29
Sahi
  • 1,454
  • 1
  • 13
  • 32

1 Answers1

2

If a span is empty it doesn't have any width or height, therefore you can't click it. To resolve this you can set your span do display block or inline-block and set a specific width, height:

span.model {
   display: inline-block;
   width: 50%; /*or 100px, ... */
   height: 50%; /* or 100px, ... */
}
cloned
  • 6,346
  • 4
  • 26
  • 38
  • for debug purpose you can apply span { display: inline-block; width: 50px; height: 50px; background: red; } – Sagar Aug 01 '18 at 09:09