By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,438 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

shorten a method string

P: n/a
hi. i want to shorten getElementById() string at my files.
ive writen this function:
function gebi(el){
document.getElementById(el)
}
and when i try to call an ID, i try to call him like this:
gebi('myID').
but this method doesnt succeed.
can you please assist me to achive that goal?

tnx
NeoSwf

Jan 31 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
neoswf wrote on 31 jan 2006 in comp.lang.javascript:
hi. i want to shorten getElementById() string at my files.
ive writen this function:
function gebi(el){
document.getElementById(el)
}
and when i try to call an ID, i try to call him like this:
gebi('myID').
but this method doesnt succeed.
can you please assist me to achive that goal?


function gebi(el){
return document.getElementById(el);
}

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 31 '06 #2

P: n/a
Evertjan. wrote:
function gebi(el){
return document.getElementById(el);
}


thank you Evertjan.
how can i recive this kind of result:
gebi(el).style.width?
to use this method in different usages like reciving the style object
and etc...

Jan 31 '06 #3

P: n/a
neoswf wrote:
to use this method in different usages like reciving the style object
and etc...


thank you Evertjan, its working great!

<script>
alert(gebi('shlomi').style.width);
</script>

:)

Jan 31 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.