0

is there any way that i can pass a variable in function in the @click function. this is what i intend to do.

<div @click="someFunction(type=clockIn)"
  <p>some template</p>
</div>

in a html template. how can i define the variable with its value. because i have 3 template where when i click on it will on it, the someFunction will trigger and using the type value. the function is not a problem. the problem is how to define the type variable with its value.

Khairul Habib
  • 131
  • 2
  • 13

2 Answers2

1

i don't know why my brain do not function properly before. here i share the working code that i have made

<div @click="someFunction('clockIn')"
  <p>some template</p>
</div>
Khairul Habib
  • 131
  • 2
  • 13
0

Yeah, you can just pass it into the onClick -

HTML >>>>

<p onclick="myFunction(myVariable)">

JS >>>>>

function myFunction(e){
    console.log(e);
}

var myVariable = 'Variable'

Result >>>>

Variable

:)

Wally
  • 705
  • 1
  • 9
  • 24
  • yeahh at first i don't know why can't i brainstorm the logic. maybe it's too much thing i need to think. a while after i post this question just i remembered. – Khairul Habib Nov 19 '19 at 06:40
  • staring at a screen all day has that effect - the knowedge is there just needed another coffee to come out and play – Wally Nov 19 '19 at 06:53