Yesterday I have put the question which was answered correctly but now I want to convert that same code into javascript. I have made some changes but its not work
working code- http://jsfiddle.net/SXzyR/8/
mycode- http://jsfiddle.net/SXzyR/11/
Yesterday I have put the question which was answered correctly but now I want to convert that same code into javascript. I have made some changes but its not work
working code- http://jsfiddle.net/SXzyR/8/
mycode- http://jsfiddle.net/SXzyR/11/
You want to use this.id instead of document.getElementById(this) to get the id string where this is a DOM element.
Please read some tutorials about jQuery. This is a good start, also have a look here.
jQuery isn't another language, it's a library for JavaScript. Considering the following line from your "translated" code:
txtval(document.getElementById(this)
Instead of writing document.getElementById you can simply use jQuery to write
txtval($(this))
as in the first example (working code).
Also you are mixing jQuery with "native" JavaScript/DOM functions in your code. Don't reinvent the wheel, use jQuery to accomplish your task.
document.getElementById(this.id) or document.getElementById($(this).attr('id')) to pass the id, not the DOM element...