/    Sign up×
Community /Pin to ProfileBookmark

DOM and functions with a return value

alright, i’m checking out the DOM (which has pretty cool methods)

so far i’ve got this: (its simplified)

[code=php]function mnu() {

var thismenu=name;

var mDiv = document.createElement(“div”);

mDiv.getVisibility=function() { thismenu.getVisibility(this); }

alert(mDiv.getVisibility());

document.body.appendChild(mDiv);

}

mnu.prototype.getVisibility=function(div) {
if (div.style.visibility==’none’ || div.style.visibility==’hidden’) {
return ‘hidden’;
}
else {
return ‘visible’;
}
}[/code]

so i attach a function to mDiv, which (should) returns visible or hidden, but it doesn’t, i get an [b]undefined[/b]

but when i put alert boxes in the function itself (in the if-clause), it gives me the correct values

can anybody help me?

grtz

edit: switched visible and hidden

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 29.2004 — [URL=http://www.w3.org/TR/REC-CSS2/visufx.html#visibility]visibility[/URL] is visible | hidden | collapse ; not none.

The statements in the [I]ifelse[/I] should be reversed.
Copy linkTweet thisAlerts:
@violent_jauthorApr 29.2004 — IE has an extra option "none", i included it just to be sure

but the if-clause is correct, as i said, when i put an alert box where the value is to be returned it gives the correct result, but the function doesn't return anything

grtz

edit: hehe i know see what you mean, it gives visible when it's hidden and vice versa, i'll correct that immediately ?
Copy linkTweet thisAlerts:
@violent_jauthorApr 29.2004 — BUMP

somebody??
×

Success!

Help @violent_j 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.18,
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,
)...