Answer the question
In order to leave comments, you need to log in
How to get button attributes?
There is this piece of code:
<div className="pBtn">
<Button
block
bsSize="large"
onClick={props.arrowHandler}
id="la-la-la"
value={1}
>
<Image src={require('../../styles/iconcs/arrow.png')} fluid />;
</Button>
</div>
...
arrowHandler = event => {
console.log(event)
}
event.target.value
) returns the value of the element nested in the button instead of the value of the button itself.
Answer the question
In order to leave comments, you need to log in
currentTarget :
Or, there is an option not to set the attribute at all, but to pass the desired value to the handler (no, I wouldn’t do it myself - an extra function is created, plus you have to rewrite the handler):
event.currentTarget.getAttribute('имя_атрибута')
onClick={e => props.arrowHandler(e, VALUE)}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question