我希望有人可以帮助我,我在onclick选项卡上遇到了一些麻烦。我的所有标签都适用于IOS设备,但不适用于Android。我从W3Sschools获得了代码,这是我的代码:
<div class="col-md-6 next-slider">
<ul class="tab tab-content">
<li><a class="tablinks" onclick="openCity(event, 'ROOMS')">ROOMS</a></li>
<li><a class="tablinks" onclick="openCity(event, 'MEALS')">MEALS</a></li>
<li><a class="tablinks" onclick="openCity(event, 'FACILITIES')">FACILITIES</a></li>
<li><a class="tablinks" onclick="openCity(event, 'VISITING')">VISITING</a></li>
<li><a class="tablinks" onclick="openCity(event, 'SOCIAL')">SOCIAL</a></li>
</ul>
<div id="ROOMS" class="tabcontent">
<h3>ROOMS</h3>
<p>All single bedrooms, most en-suite. All bedrooms are tastefully decorated and have a TV and nurse call bell. If residents wish they can bring some of their personal items and furniture.</p >
</div>
<div id="MEALS" class="tabcontent">
<h3>MEALS</h3>
<p>We offer a very extensive menu of home cooked meals including popular dishes such as hotpot, shepherds pie and fish & chips every Friday. Residents have a say when planning these and may take meals in their rooms when required. Special diets are catered for.</p>
</div>
<div id="FACILITIES" class="tabcontent">
<h3>FACILITIES</h3>
<p>Each floor has its own large lounge and spacious dining room over-looking the Bay. Bath/shower rooms situated on all floors, easy wheelchair access throughout the building. Ground floor is Residential Care and the first, second and third floors are Nursing Care.</p>
</div>
<div id="VISITING" class="tabcontent">
<h3>VISITING</h3>
<p>Relatives and friends are welcome at any time throughout the day. (We do ask that residents are not disturbed at mealtimes.) If you require any further details please do not hesitate to contact us.</p>
</div>
<div id="SOCIAL" class="tabcontent">
<h3>SOCIAL</h3>
<p>There are regular activities organised by our own Social Activities Organiser, Jacqui. These include
Bingo, which is held twice a week and various other classes such as Painting, Music & Movement, Crafts, Quizzes and Reminiscing of Past Times.</p>
<p>An entertainer attends The Sands once a month, singing the residents' favourite songs.
Pantomimes are held at Christmas time, and charity fund-raising events are held throughout the year, in which residents are welcome to get involved.</p>
<p><strong>Monday</strong><br>
Bingo
1.30 pm Keswick Suite Lounge </p>
<p><strong>Tuesday</strong><br>
Word Games
10.15 am Grasmere Suite Lounge <br>
Music & Movement
1.30pm Derwent Suite Lounge </p>
<p><strong>Thursday</strong><br>
Painting or Dominoes
10.15 am Keswick Suite Dining Room </p>
<p><strong>Friday</strong><br>
Reminiscence Group
10.15 am Keswick Suite Lounge<br>
Bingo
1.30 pm Keswick Suite Lounge</p>
</div>
<script>
$( function() {
$( "#tabs" ).tabs();
} );
</script>
我不确定,但我有一个js文件:
// JavaScript Document
function openCity(evt, cityName) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the link that opened the tab
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
如果有人有帮助,我会非常感激。
亲切的问候,
詹姆斯
答案 0 :(得分:0)
请尝试以下代码:
onclick="(function(){openCity(event, 'ROOMS');})()"