Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
114
rated 0 times [  118] [ 4]  / answers: 1 / hits: 91437  / 11 Years ago, sun, may 26, 2013, 12:00:00

I have a button like following



<input type='button' value='Generate' onclick='f1()' />


now the f1 function should show a alert box contain button value. in this case 'Generate'



How to do this?



I tried



alert(this);
alert(this.val());


it does not work


More From » javascript

 Answers
5

Try this.



<input type='button' value='Generate' onclick='f1(this)' />


Now alert like



function f1(objButton){  
alert(objButton.value);
}


P.S: val() is actually a jQuery implementation of value


[#78018] Friday, May 24, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
destiney

Total Points: 175
Total Questions: 96
Total Answers: 93

Location: Zambia
Member since Sat, Nov 6, 2021
3 Years ago
;