拉斐尔没有使用jquery在asp.net页面上找到元素
|
我是Raphael的新手,无法从现有元素创建Raphael对象。
下面的代码显示了我尝试过的内容以及每个人造成的错误。理想情况下,我想在首次调用Raphael时使用jquery创建对象。
任何帮助将非常感激。
<%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"WebForm2.aspx.cs\" Inherits=\"Fleetstar.UI.WebForm2\" %>
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head runat=\"server\">
<script src=\"js/raphael.js\" type=\"text/javascript\"></script>
<script src=\"js/jquery.js\" type=\"text/javascript\"></script>
<script type=\"text/javascript\">
$(document).ready(function () {
var thisWorks = document.getElementById(\'imgMap\'); // This works
var thisAlsoWorks = $(\'.mapClass\'); //thsi.works
var thisDoeNotWorkA = Raphael(document.getElementById(\'imgMap\'), 200, 200); //Error: Unexpected call to method or property access.
var thisDoeNotWorkB = Raphael(document.getElementById(\'imgMap\')[0], 200, 200); //Error: \'tagName\' is null or not an object
var thisDoeNotWorkC = Raphael(document.getElementById(\'imgMap\').node, 200, 200); //// Error: \'tagName\' is null or not an object
var thisDoeNotWorkD = Raphael($(\'.mapClass\'), 200, 200); //Error: \'container\' is null or not an object
var thisDoeNotWorkE = Raphael($(\'.mapClass\').node, 200, 200); // Error: \'tagName\' is null or not an object
var thisDoeNotWorkF = Raphael($(\'.mapClass\')[0], 200, 200); //Error: Unexpected call to method or property access.
var thisDoeNotWorkG = Raphael($(\'[id$=\"imgMap\"]\'), 200, 200); // Error: \'container\' is null or not an object
var thisDoeNotWorkH = Raphael($(\'[id$=\"imgMap\"]\')[0], 200, 200); //Error: Unexpected call to method or property access.
var thisDoeNotWorkI = Raphael($(\'[id$=\"imgMap\"]\').node, 200, 200); //Error: \'tagName\' is null or not an object
});
</script>
</head>
<body>
<form id=\"form1\" runat=\"server\">
<img class=\"mapClass\" id=\"imgMap\" name=\"imgMapName\" style=\"position: absolute\" src=\"Images/map.gif\"
alt=\"\" />
</form>
没有找到相关结果
已邀请:
2 个回复
杭难插
http://raphaeljs.com/reference.html#Raphael上的规范说您要传递节点ID。 编辑:如果那不起作用,那么可能是元素ID被其他东西修改了吗?
僻朵庙惩竣