Jquery 将额外的 # 附加到 DOM 对象
Jquery appending extra # to DOM objects
我在IE9中收到以下错误
SCRIPT5022:语法错误,无法识别的表达式:##chart1jquery-2.0.3.min.js,第 4 行字符 14519
我不确定为什么给定下面显示的代码。我显然没有将其添加到 HTML 字符串中,当我在 jqplot 调用中引用它时只有 1。那么,为什么它会弹出此错误呢?
function createGraph() {
var HTMLstring = '<!DOCTYPE html>'n';
HTMLstring += '<HTML>'n';
HTMLstring += '<HEAD>'n';
HTMLstring += '<TITLE> Frequency Graph</TITLE>'n';
HTMLstring += '<!--[if lt IE 9]><script src="js/excanvas.js"></script><![endif]-->'n';
HTMLstring += '<script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>'n';
HTMLstring += '</HEAD>'n';
HTMLstring += '<BODY>'n';
HTMLstring += '<div><span>Moused Over: </span><span id="infomouseover">Nothing</span></div>'n';
HTMLstring += '<div><span>Clicked: </span><span id="infoclicked">Nothing</span></div>'n';
HTMLstring += '<div id="chart1" style="margin-top:20px; margin-left:20px; width:300px; height:300px;"></div>'n';
HTMLstring += '</BODY>'n';
HTMLstring += '</HTML>';
newwindow = window.open();
newdocument = newwindow.document;
newdocument.write(HTMLstring);
$(document).ready(function () {
freqchart = $.jqplot('#chart1', [
[
[2, 1],
[4, 2],
[6, 3],
[3, 4]
],
[
[5, 1],
[1, 2],
[3, 3],
[4, 4]
],
[
[4, 1],
[7, 2],
[1, 3],
[2, 4]
]
], {
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
pointLabels: {
show: true,
location: 'e',
edgeTolerance: -15
},
shadowAngle: 135,
rendererOptions: {
barDirection: 'horizontal'
}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer
}
}
});
$('#chart1').bind('jqplotDataHighlight',
function (ev, seriesIndex, pointIndex, data) {
$('#infomouseover').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data + ', pageX: ' + ev.pageX + ', pageY: ' + ev.pageY);
}
);
$('#chart1').bind('jqplotDataClick',
function (ev, seriesIndex, pointIndex, data) {
$('#infoclicked').html('series: ' + seriesIndex + ', point: ' + pointIndex + ', data: ' + data + ', pageX: ' + ev.pageX + ', pageY: ' + ev.pageY);
}
);
$('#chart1').bind('jqplotDataUnhighlight',
function (ev) {
$('#infomouseover').html('Nothing');
}
);
});
}
jqPlot()
不需要CSS样式选择器来查找Id。它自己处理,因此目前它会两次查找附加#
的#chart1
。
<script>
//This will look for #chart1
$.jqplot('chart1', [data], options );
</script>
jsplot 文档
"通过使用目标的 id 调用
$.jqplot()
插件来创建实际情节"
jqplot 将元素 id 作为参数而不是 id 选择器,因此应该$.jqplot('chart1',
$.jqplot('#chart1',
等。
http://www.jqplot.com/docs/files/usage-txt.html
相关文章:
- 将GET请求(HTML字符串)转换为完整的DOM对象
- 在Angular中呈现DOM对象时,如何调用控制器中指定的函数
- 不带dom对象的jquery ajaxComplete()
- 从 DOM 数组中删除 DOM 对象
- Raphael JS:如何从 Dom 对象(Element.node)获取 Raphael 元素
- SVG DOM对象间距/重叠
- DOM对象而不是其他DOM对象
- 如何区分DOM对象和JavaScript对象
- 在提取dom对象后,无法将每个名为tab的元素推送到数组中
- M项目2:是否可以从DOM对象中获取M视图
- Javascript关闭DOM对象事件和事件冒泡
- 如何使用jQuery将重复类添加到DOM对象中
- 当请求DOM对象时,XMLHttpRequest.send()抛出异常
- 从非DOM对象内部调度和处理自定义事件
- dom对象创建javascript和jquery后的事件触发器
- 使用Internet Explorer检索XML DOM对象的URI
- 如何将事件绑定到没有DOM对象的函数
- 使用 Aurelia动态创建一个 dom 对象
- 使用 jQuery 操作 DOM 对象
- 使用多个 css 类将 css 转换属性应用于 DOM 对象时遇到问题