Raphael Javascript text not displaying correctly

自古美人都是妖i 提交于 2019-12-11 05:46:45

问题


I have some text being displayed and I am using the Raphael JS library. I want the 'firstname' text to be size 25px, but it is not working. I am passing in a JS variable to the Raphael part and maybe that is part of the problem. If anyone could help me I would appreciate it.

<html> 
<head> 
<script src="raphael.js"></script> 
<script src="jquery-1.7.2.js"></script>  
<script type="text/javascript">   

var string = "J\no\ne"; 

</script>
</head> 

<body>  

Text: <input type="text" id="words" value="" /> 
<input type="button" value="Animate" onclick="animate()" /> 
<div id='msg'></div> 
<div id='num'></div>
<div id='letters'></div>
<!--<div id="letters2"></div>-->
<div id="draw-here-raphael" style="height: 200px; width: 400px; margin-top:0px;"> 
</div> 
<div id="elps" style="margin-left:100px;"/>  

<script type="text/javascript"> //all your javascript goes here  
var r = new Raphael("draw-here-raphael"); 
var firstname = r.text(95,100, string).attr({font: "25px"}); 
var name = r.text(100,100, string);
name.blur(1);
</script>

</body> 
</html>

回答1:


Try var firstname = r.text(95,100, string).attr({"font-size": 25});




回答2:


Try calling the raphael js file after the jQuery file.

<script src="jquery-1.7.2.js"></script>
<script src="raphael.js"></script> 


来源:https://stackoverflow.com/questions/11613079/raphael-javascript-text-not-displaying-correctly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!