簡體   English   中英

JS“重新加載”div元素內容而不刷新頁面

[英]JS 'reload' div element content without refreshing page

我使用畫布從chartJS 購買了購物車。

在此處輸入圖片說明

當我將鼠標懸停在我網站的側邊欄上時,頁面布局會發生變化並且圖表不再適合框,因為它的尺寸大於白框尺寸。

這條線正在脫離白盒。

但是當我此時重新加載頁面時,一切都很完美。

我的問題:

有沒有辦法添加事件或其他東西,當我將鼠標懸停在側邊欄上時圖表元素寬度會更新,或者重新加載該元素以便它可以自動適合框,而無需刷新頁面?

在此處輸入圖片說明

mouseover事件,您可以使用其中之一:

let sidebar = document.querySelector(".sidebar");
  
// This handler will be executed only once when the cursor
// moves over the unordered list
sidebar.addEventListener("mouseenter", function( event ) {   
  // call chartJS here
});

let sidebar = document.querySelector(".sidebar");

// This handler will be executed every time the cursor
// is moved over a different list item
sidebar.addEventListener("mouseover", function( event ) {   
  // call chartJS here
});

有關活動的更多信息,請訪問此頁面: https : //developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM