jQuery - 如何在 jquery 中访问 “this.options” dataSousrce 属性
jQuery - How to access "this.options" dataSousrce attribute in jquery
我只想访问dataSource
属性this.options
我们如何访问。
我用了console.log(this.options)
,它给了我下面
Object {swfSrcPath: undefined, product: "v3", insertMode: "replace", safeMode: true, overlayButton: undefined…}{
autoInstallRedirect: false
chartType: undefined
containerBackgroundColor: "#ffffff"
containerElement: div#impact-report-user-filter.context
containerElementId: "impact-report-user-filter"
dataConfiguration: undefined
dataFormat: "xml"
dataSource:
<chart caption='Filter By' labelDisplay='AUTO' useEllipsesWhenOverflow='1' subcaption='' xAxisName='Compliance' yAxisName='Impact of Failure' bgColor='FFAAAA,FFFFFF' exportEnabled='1' exportAtClient='1' exportHandler='fcExporter1' showLabels='0' showValues='0' showLegend='1' legendBorderAlpha='0' legendBgAlpha='0' legendShadow='0' formatNumberScale='0'>
<set label='Mumbai' value='1' displayValue='Mumbai' link='url'/>
<set label='Bangalore' value='1' displayValue='Bangalore' link='url'/>
</chart>
insertMode: "replace"
overlayButton: undefined
product: "v3"
renderer: "flash"
safeMode: true
showDataLoadingMessage: true
swfSrcPath: undefined
useLegacyXMLTransport: false
__proto__: Object
}
我们有一个属性dataSource
,我想访问每个标签属性的设置标签值。请帮助访问Mumbai
、Bangalore
和available all set tag label
您可以使用
$.parseXML()
获取dataSource
并解析 xml 。由于有多个 set
xmls 对象,因此您需要使用 $.each()
遍历这些对象。
JS代码:
var parsedXml = $.parseXML(xmlr);
var sets = $(parsedXml).find('set');
$(sets).each(function() {
console.log($(this).attr('label'));
});
现场演示 @ JSFiddle
相关文章:
- $(this).prop('property') vs. this.property
- Twitter Bootstrap typeahead:使用“this”获取上下文/调用元素
- 在另一个函数中使用变量this
- this.router在AngularJS 2中未定义
- reactjs this.refs vs document.getElementById
- JavaScript 中的嵌套函数和 “this” 关键字
- React+Meteor:this.ops返回未定义
- javascript中对象构造函数中的var属性与this.properties
- 函数中this和var之间的区别
- jQuery(this).Pparent().Pparente().Prent().find()在iPad上不起作用
- Understanding Javascript scope with "var that = this&qu
- 定义this.properties或objectName.properties的javascript JSON对象
- Object.prototype using 'this'
- 在JavaScript类型的函数中避免self-this
- 如何使用(this)访问Angular 2 http rxjs catch函数中的对象属性
- Jquery Options using $(this)
- jQuery - 如何在 jquery 中访问 “this.options” dataSousrce 属性
- c.easing[this.options.specialEasing&this.options.sespeci
- 对象函数(){location.href=this.options.url);没有方法'apply'
- "类型错误:this.options为null"在OpenLayers.Protocol.HTTP中