问题
I use touch monitor and html page (MS Windows 7 Pro Eng, IE8). And I discovered that touch fires when text area of li tag is tapped and the rest is ignored.
How change it so even if user tap on white/non-text area of the li it fires as it should.
<link href="css/bootstrap.min.css" rel="stylesheet" />
<script src="jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="jquery.mobile-1.4.5.min.js" type="text/javascript"></script>
<ul class="nav" id="mainList">
<li class="touchedLi stripe-even" id="item0"><a href="#">Club Yellow 1</a></li>
<li class="touchedLi stripe-odd" id="item1"><a href="#">Club Yellow 2</a></li>
<li class="touchedLi stripe-even" id="item2"><a href="#">Club Yellow 3</a></li>
</ul>
CSS
li.stripe-even {
background-color: #FFF1ED;
list-style-type: none;
}
li.stripe-odd{
background-color: #F2FFED;
list-style-type:none;
}
ul.mainList li:hover{
background-color: yellow;
}
#mainList a:active {
color: white;
background-color: orange;
}
#mainList>li>a {
display: block;
}
li.stripe-even {
background-color: #FFF1ED;
list-style-type: none;
}
li.stripe-odd{
background-color: #F2FFED;
list-style-type:none;
}
ul.mainList li:hover{
background-color: yellow;
}
#mainList a:active {
color: white;
background-color: orange;
}
#mainList>li>a {
display: block;
}
#mainList>li {
display: block;
}
#mainList>li {
display: block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<ul class="nav" id="mainList">
<li class="touchedLi stripe-even" id="item0"><a href="#">Club Yellow 1</a></li>
<li class="touchedLi stripe-odd" id="item1"><a href="#">Club Yellow 2</a></li>
<li class="touchedLi stripe-even" id="item2"><a href="#">Club Yellow 3</a></li>
</ul>
回答1:
So I found working solution
Nothing is working but only
So the li tag should look like this
<ul class="nav" id="mainList">
<li class="touchedLi stripe-even" id="item0"><a href="#">Club Yellow 1 </a></li>
<li class="touchedLi stripe-odd" id="item1"><a href="#">Club Yellow 2 </a></li>
<li class="touchedLi stripe-even" id="item2"><a href="#">Club Yellow 3 </a></li>
</ul>
And then the area of is a touchable area! :)
How you are gonna add it depends of your needs.
回答2:
What is your CSS? Try adding display: block to the a tag.
来源:https://stackoverflow.com/questions/37468978/no-touch-event-for-li-tag