jqueryのかなり初心者です。私はnavbarと私が選択したものに基づいて自分のタグを変更しようとしている。 h1タグはjquery .html()によって変更されません。
$(document).ready(function() {
\t $('a').click(function(){
\t the = $(this).html();
\t linkvalue = $(this).attr('data-link');
\t $('#whatItIs').html(the);
\t console.log(the);
\t console.log(linkvalue);
\t
\t switch(the) {
\t case "Steel Products":
\t \t { \t
\t \t \t window.location.href = linkvalue;
\t \t break;
\t \t }
\t case "Steel Doors":
\t { \t
\t \t
\t \t window.location.href = linkvalue;
\t \t break;
\t \t }
\t case "Digital Safes":
\t \t {
\t \t
\t \t window.location.href = linkvalue;
\t \t break;
\t \t }
\t case "Security Equipment":
\t \t {
\t \t \t \t
\t \t window.location.href = linkvalue;
\t \t break;
\t \t } \t
\t case "Storage Solutions":
\t \t {
\t \t \t
\t \t window.location.href = linkvalue;
\t \t break;
\t \t }
\t case "Steel Furniture":
\t \t {
\t \t
\t \t window.location.href = linkvalue;
\t \t break;
\t }
\t default:
\t {
\t console.log("Not Found");
\t //window.location.href = "404.html";
\t }
\t }
\t });
});
<li class="dropdown" class="active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Manufactured Products <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a data-link="securityEquipment.html">Steel Products</a>
</li>
<li>
<a data-link="securityEquipment.html">Steel Doors</a>
</li>
<li >
<a data-link="securityEquipment.html">Digital Safes</a>
</li >
<li>
<a data-link="securityEquipment.html">Security Equipment</a>
</li>
<li >
<a data-link="securityEquipment.html">Storage Solutions</a>
</li>
<li>
<a data-link ="securityEquipment.html">Steel Furniture</a>
</li>
</ul>
</li>
<h1 class="page-header" id="whatItIs">
Untitled
<!-- <small>Subheading</small>
--> </h1>
問題は、その後のH1だけ第二の変更とバック私はそれが設定されている元に変化することです。 これはかなりシンプルなようです。私は間違って何をしているのか分かりません
それはですあなたはクリックしません。 –
リンクで通常のhref属性を使用してみませんか?あなたは通常のブラウザの動作を複製しているようです。 – jedifans
@jedifans私はこれ以上の機能を実装する必要があります。私はその部分に慣れていない。私はこの作業を得ることができない – spetiwala