久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

加載新頁面后,HTML 面包屑顯示然后丟失位置

HTML Breadcrumb Displaying Then Losing Location Once New Page Is Loaded(加載新頁面后,HTML 面包屑顯示然后丟失位置)
本文介紹了加載新頁面后,HTML 面包屑顯示然后丟失位置的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的網站上的面包屑導航有問題.

I have an issue with the breadcrumb on my site.

在頁面加載時,會顯示主頁(這是正確的).當我點擊導航菜單中的鏈接時,面包屑會更新為:

On page load, the Home is displayed (which is correct).. When i click on a link within my navigation menu, the breadcrumb is updated with say:

首頁 > 新頁面

但是,當加載新頁面時,面包屑會返回到僅顯示主頁.

However, when the New Page is loaded, the breadcrumb goes back to only displaying Home.

我的導航 JSP 文件:

My Navigation JSP file:

<nav class="nav">
  <ul class="wrap">

    <li class="menu-nav--home">
      <a href="/home" title="home">
        <span class="icon-home"></span>
      </a>
    </li>
    <ul>
      <li><a href="/business">Business</a></li>
      <li><a href="/search">Search</a></li>
      <li><a href="/details">Search Deatils</a></li>
      <li><a href="/update">Change Records</a></li>
      <li><a href="/delete">Remove</a></li>
      <li><a href="/order">Order Deatils</a></li>
      <li><a href="/checkout">Checkout</a></li>
    </ul>
  </li>
</ul>
</nav>

<div class="wrap breadcrumb">
  <div class="item">
    <a href="#home">Home </a>
  </div>
</div>

我的 jQuery 代碼:

My jQuery code:

$(function() {
  createBreadcrumbs();      
}

function createBreadcrumbs() {
  $('.site-nav a').on('click', function() {
    var $this = $(this),
    $bc = $('<div class="item"></div>');

    $this.parents('li').each(function(n, li) {
      var $a = $(li).children('a').clone();
      $bc.prepend(' > ', $a);
    });

    $('.breadcrumb').html( $bc.prepend('<a href="/">Home </a>') );    
    return false;
  });

任何幫助表示贊賞.

我已嘗試遵循此處的建議 - jquery - 動態面包屑

I have attempted to follow the advice found here - jquery - dynamic breadcrumb

謝謝

推薦答案

您的代碼中有幾個錯誤.首先,您忘記了以下代碼中的 );:

There are a couple of errors in your code. First of all, you are forgetting a ); in the following code:

$(function() {
  createBreadcrumbs();      
} ); //HERE!

您可能忘記將最后一個 } 復制到此問題中.我在這里添加了那個.您正在將處理程序附加到作為具有 site-nav 類的元素的子元素的鏈接.您的代碼中沒有這樣的東西.將其更改為 .nav a.

and you might have forgotten to copy the last } to this question. I've added that one in here. You are attaching a handler to links that are a child of an element with the site-nav class. There is no such thing in your code. Change that to .nav a.

function createBreadcrumbs() {
  $('.nav a').on('click', function() {
    var $this = $(this),
    $bc = $('<div class="item"></div>');

    $this.parents('li').each(function(n, li) {
      var $a = $(li).children('a').clone();
      $bc.prepend(' > ', $a);
    });

    $('.breadcrumb').html( $bc.prepend('<a href="/">Home </a>') );    
    return false;
  });
}

如果您希望它實際顯示某些內容,則需要使用 ajax 加載頁面并將生成的 html 推送到 DOM 中.

If you want this to actually display something, you'll need to load the page with ajax and shove the resulting html into the DOM.

這篇關于加載新頁面后,HTML 面包屑顯示然后丟失位置的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

jQuery/JavaScript Library for avatar creation?(用于創建頭像的 jQuery/JavaScript 庫?)
How to do following mask input problem?(如何做以下掩碼輸入問題?)
Issues Setting Value/Label Using DropKick Javascript(使用 DropKick Javascript 設置值/標簽的問題)
how to unit-test private methods in jquery plugins?(如何對 jquery 插件中的私有方法進行單元測試?)
stellar.js - configuring offsets / aligning elements for a vertical scrolling website?(stellar.js - 為垂直滾動網站配置偏移量/對齊元素?)
jQuery masked input plugin. select all content when textbox receives focus(jQuery 屏蔽輸入插件.當文本框獲得焦點時選擇所有內容)
主站蜘蛛池模板: 在线国产一区二区 | 一二三在线视频 | 国产h视频| 欧美一区二区三区在线视频 | 中文字幕国产 | 久久狼人天堂 | 伊人91在线| 国产一区二区三区不卡av | 国产一区二区中文字幕 | 欧美视频在线看 | 国产精品久久精品 | 在线看亚洲 | 日本不卡一区 | 亚洲一区二区中文字幕 | 日本高清aⅴ毛片免费 | 一级做a爰片性色毛片16美国 | 性做久久久久久免费观看欧美 | 久久精品成人热国产成 | 四虎永久免费影院 | 日本精品视频在线 | 亚洲一区三区在线观看 | 91干b| 99久久精品国产一区二区三区 | 欧美精品91| 亚洲欧洲中文日韩 | 中文字幕综合在线 | 精品国产乱码久久久久久中文 | 国产一区二区中文字幕 | 最新高清无码专区 | 精品少妇一区二区三区日产乱码 | 日韩字幕 | 亚洲视频一区在线观看 | 在线一区二区观看 | 欧美综合视频 | 亚洲视频手机在线 | 中文字幕视频在线看5 | 欧美做暖暖视频 | 国产精品成人品 | 电影午夜精品一区二区三区 | 欧美专区在线 | 麻豆国产一区二区三区四区 |