为什么console.log记录$(this).data
Why is console.log logging $(this).data?
为什么我的控制台记录$(this).data?当我控制台记录变量时,我得到了未定义。
我需要访问chartType
才能与代码一起移动:
if ($(this).hasClass("points")){
chartType = $(this).data('chart-type');
console.log($(this));
console.log(chartType);
}
以下是它记录的内容(Stack Overflow不会让我把它的控制台放在第一行,但它确实存在)
undefined
您可以使用jquery attr()来选择属性。
if ($(this).hasClass("points")){
chartType = $(this).attr('data-custom-value');
console.log($(this));
console.log(chartType);
}
相关文章:
- $(this).prop('property') vs. this.property
- Ember Data DS.Model's set函数不起作用
- AJAX 请求没有在我的 React 组件中设置 this.state.data
- jQuery this.data-x 不起作用
- ReactJS:this.props.data.map 不是一个函数
- $(this).data() 修剪从数据库中传递的数据,直到出现空格
- 它是如何工作的?target=$this.attr('data target')|| e.prevent
- 未捕获类型错误:this.props.data.map不是函数(使用超级代理)
- 如何使yield工作与this.req.on('data'),而不需要更多的模块
- jQuery 选择器 - “this”或“data”
- ParseReact.Mixin如何侦听this.data的更改?
- 事件处理程序错误:“this.data()不是一个函数”
- JQuery: $(this).data('pinned')到底是做什么的?
- 未捕获的类型错误:this.state.data.map不是一个函数
- JS:无法读取jquery事件中的this.data()
- Getting undefined for this.props.data
- ReactJS this.props.data is undefined
- 为什么console.log记录$(this).data
- Uncaught TypeError: this.props.data.map不是一个函数
- 未捕获的类型错误:this.props.data.map不是函数