Reputation: 3576
This HTML:
<li value="16-May-2017" data-reactid=".0.1.0.0.1.2.2.$16">16test</li>
I'm trying to retrieve the value of, with this React.js code:
selectDate(event) {
event.preventDefault();
console.log(event.target.value);
if(this.state.whichDate == 0) {
this.state.selectedToDate = event.target.value
this.state.whichDate = 1
} else {
this.state.selectedFromDate = event.target.value
this.state.whichDate = 0
}
}
However, I get "16" printed to console instead of "16-May-2017".
I thought it might be printing the text between the tags, but it can't be as I put test there to see... maybe it's not printing anything after the hyphen in the value?
Upvotes: 2
Views: 17128
Reputation: 6339
What you want is:
console.log(event.target.getAttribute('value'));
Upvotes: 11