该控制台为什么不记录点击值?!它来不确定。 因为这不是箭头功能,应该是它单击的div?
let boxes = document.querySelectorAll('.box');
for(var i=0;i<boxes.length;i++) {
boxes[i].addEventListener('click',function(e) {
console.log(this.value)
})
}
<div class="wrapper">
<div class="box" value="box1" name='test'>1</div>
<div class="box" value="box2">2</div>
<div class="box" value="box3">3</div>
<div class="box" value="box4">4</div>
<div class="box" value="box5">5</div>
<div class="box" value="box6">6</div>
</div>
答案 0 :(得分:3)
string
没有名为{
onchange: function(){
console.log("I been changed now!")
},
validate: function(obj){
console.log("I be validatin' now!")
},
elements: {
"list": {
menu: [{
caption: "Append an <item>",
action: Xonomy.newElementChild,
actionParameter: "<item/>"
}]
},
"item": {
menu: [{
caption: "Add @label=\"something\"",
action: Xonomy.newAttribute,
actionParameter: {name: "label", value: "something"},
hideIf: function(jsElement){
return jsElement.hasAttribute("label");
}
}, {
caption: "Delete this <item>",
action: Xonomy.deleteElement
}, {
caption: "New <item> before this",
action: Xonomy.newElementBefore,
actionParameter: "<item/>"
}, {
caption: "New <item> after this",
action: Xonomy.newElementAfter,
actionParameter: "<item/>"
}],
canDropTo: ["list"],
attributes: {
"label": {
asker: Xonomy.askString,
menu: [{
caption: "Delete this @label",
action: Xonomy.deleteAttribute
}]
}
}
}
}
}
的任何属性。您可以从here进行检查。如果仍要使用它,请使用div
value
getAttribute
答案 1 :(得分:-1)
像这样尝试div
中的值:
console.log(this.innerHTML)
对于值in属性
console.log(this.getAttribute('value'))