/    Sign up×
Community /Pin to ProfileBookmark

how to pass an element to a function?

Hi,

I know i can pass an element to a function by its id, but the id has been used for other purpose – show/hide, so i nned another element property to pass rather than id, how to do that?

thanks

i am new to javascript, following is my code, please help

problem is second param of eleSH in function ShowHideElement(…)
======================================

<html>

<head>
<title>Welcome</title>

<style type=”text/css”>
#seenot00
{
display:none;
}
#seeyes00
{
display:yes;
}
</style>

<script LANGUAGE=”JavaScript”>

function ShowHideElement(eleMy,eleSH,bShow,strMore,strLess)
{
if(bShow)
{
eleSH.id =”seeyes00″;
eleMy.innerHTML =strLess;
}
else
{
eleSH.id =”seenotyes”;
eleMy.innerHTML =strMore;
}
}
</script>

</head>

<body>

Put some text here then click to <br>
(read <u><font color=’#000081′>
<span align=”left;” style=”cursor:pointer;”
onMouseOver=”ShowHideElement(this,goodonyou,true,’more’,’less’);”
onMouseOut=”ShowHideElement(this,goodonyou,false,’more’,’less’);”>
more
</span></font></u> …)

<div name=”goodonyouoo” id=”goodonyou”;>
<!———————————–>
<font size=”8″ color=”FF0000″>
Add your code to show/hide in this part.
</font>
<!———————————–>
</div>

</body>
</html>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@hi_itsmeJun 20.2007 — Hi,

I have not understood ur requirement exactly...

I will explain what have i understood...

Onmouseover 'more' must change to 'less', the div named 'goodonyou' must be shown and onmouseout revert all back....

If so here is the coding

<html>

<head>

<title>Welcome</title>

<style type="text/css">

#seenot00

{

display:none;

}

#seeyes00

{

display:yes;

}

</style>

<script LANGUAGE="JavaScript">

function ShowHideElement(eleMy,eleSH,bShow,strMore,strLess)

{

if(bShow)

{

//eleSH.id ="seeyes00";

eleMy.innerHTML =strLess;

document.getElementById('goodonyou').style.display = ''

}

else

{

//eleSH.id ="seenotyes";

eleMy.innerHTML =strMore;

document.getElementById('goodonyou').style.display = 'none'

}

}

</script>

</head>

<body>

Put some text here then click to <br>

(read <u><font color='#000081'>

<span align="left;" style="cursor:pointer;"

onMouseOver="ShowHideElement(this,goodonyou,true,'more','less');"

onMouseOut="ShowHideElement(this,goodonyou,false,'more','less');">

more

</span></font></u> ...)

<div name="goodonyouoo" id="goodonyou" style="display:none">

<!----------------------------------->

<font size="8" color="FF0000">

Add your code to show/hide in this part.

</font>

<!----------------------------------->

</div>

</body>

</html>
×

Success!

Help @html20009876 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...