html2svg

在项目中遇到一个问题,将html转svg,载网上找了好多资料,此处记录一下,方便自己和各位朋友以后的使用,话不多说,直接上:

 

 

html代码:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>test</title>

<link rel="stylesheet" href="bootstrap.min.css">

<script type="text/javascript" src="jquery-1.8.3.min.js"></script>

<script type="text/javascript" src="lodash.min.js"></script>

<script type="text/javascript" src="convert.js"></script>

<script type="text/javascript">

$(function(){

 

$("#testButton").click(function(){

 

 

var svg = html2svg(document.getElementById("ServiceRecommendationsDiv"));

 

$("#testSvg").append(svg);

 

})

 

 

 

 

});

 

</script>

 

 

</head>

<body>

<div id="ServiceRecommendationsDiv" style="border:dotted thin;  height: auto;" align="left">

<h3>Service Recommendations</h3>

 

<div>

<div>

<b>STAR Health Service Coordination</b>

</div>

 

<div>

Youth has met the criteria for Star Health Service Coordination follow-up. (STAR Health Member Services 1-866-912-6283)

</div>

 

<div>

<b>Psychological Testing</b>

</div>

 

<div>

Youth has met the criteria for Psychological Testing.  If the child has not received psychological testing in the past, make a referral for psychological testing.  (STAR Health Member Services 1-866-912-6283)

</div>

 

<div>

<b> Developmental Disability Specialists</b>

</div>

 

<div>

Youth has met the criteria for a referral to the regional Developmental Disability Specialist.

</div>

 

</div>

 

 

 

</div>

<button id="testButton" >appendSVG</button>

<div id="testSvg" ></div>

 

</body>

 

 

</html>

 

代码中标注部分用到了几个插件,一并附上

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值