Tuesday, 15 April 2014

get value of value attribute usind id in javascript -



get value of value attribute usind id in javascript -

i want value of value attribute using id attribute of html tag.

<p id='abc' value='xyz'>123456</p>

and javascript

var a=document.getelementbyid(abc).innerhtml; alert(a);

this gives me alert "123456" want alert function should display me "xyz". how can these. tried getelementbyid(abc).value returns nothing.

or there ant way create tag doesn't display on browser. don't want display 123456 on browser.

try this

var = document.getelementbyid('abc').getattribute('value'); alert(a);

note argument abc in question not enclosed in quotes.

javascript

No comments:

Post a Comment