How to take screenshot of a div with JavaScript?

前端 未结 10 1691
误落风尘
误落风尘 2020-11-22 08:03

I am building something called the \"HTML Quiz\". It\'s completely ran on JavaScript and it\'s pretty cool.

At the end, a results box pops up that says \"Your Result

10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 08:38

    It's to simple you can use this code for capture the screenshot of particular area you have to define the div id in html2canvas. I'm using here 2 div-:

    div id="car"
    div id ="chartContainer"
    if you want to capture only cars then use car i'm capture here car only you can change chartContainer for capture the graph html2canvas($('#car') copy and paste this code

    
        
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    >
    
    
    
    
    

提交回复
热议问题