I have a website with some links. when a user clicks on each link it should pass different integer values which I can use in a .js file. I have to make some operations on the basis of these integer values. please help!!!
Your onclick event handler can optionally accept a MouseEventArgs parameter which Blazor will automatically include when it invokes the handler.
In order to pass a value as a parameter through the onClick handler we pass in an arrow function which returns a call to the sayHello function. In our example, that argument is a string: 'James': ... return ( <button onClick={() => sayHello('James')}>Greet</button> ); ...
example: <button onclick="updateById(`id`, `name`)">update</button> function updateById(id, name) { alert(id + name ); ... } Save this answer.
In Pass by Reference, a function is called by directly passing the reference/address of the variable as the argument. Changing the argument inside the function affects the variable passed from outside the function. In Javascript objects and arrays are passed by reference.
Though this question is most likely to get closed. You can call a function and pass the integer as parameter.
try this
<a href="#" onclick="yourFunction('1')">click1</a>
<a href="#" onclick="yourFunction('2')">click2</a>
javascript
function yourFunction(intValue){
alert(intValue);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With