Younis barznji Younis barznji - 5 months ago 24
HTML Question

Pass multiple element from inline onclick javascript function

Is it possible to send multiple element from inline javascript onclick function for example like this i tried but got undefined

<input type='text' id='elem1'/>
<input type='text' id='elem2'/>
<a onclick="functionName($('#elem1').val(),$('#elem2').val())"></a>


?

Answer

You can try this

<input type='text' id='elem1'/>
<input type='text' id='elem2'/>
<a onclick="myfunc($('#elem1').val(),$('#elem2').val())"></a>

Javascript

function myfunc(val1,val2)
{
  alert(val1);
  alert(val1);
}