/    Sign up×
Community /Pin to ProfileBookmark

javascript, using this

Hi all, I would like to ask you for help, I’m generally of the paralytic in JavaScript, a little know how other programming languages​​, I wrote something like this up and running, (happily):

[code] function czerwony(wskaznik)
{
document.getElementById(wskaznik).style.color=’#FF0000′;
}
function czarny(wskaznik)
{
document.getElementById(wskaznik).style.color=’#000000′;
}

//use:
<p id=’akapit’ onmouseover=”czerwony(‘akapit’)” onmouseout=”czarny(‘akapit’)” >blablablablablablablabla</p>[/code]

but if someone could help me write something with this? something like that:

[code]
function czerwony(wskaznik)
{
wskaznik.style.color=’#FF0000′;
}
function czarny(wskaznik)
{
wskaznik.style.color=’#000000′;
}
//use:
<p onmouseover=”czerwony(‘this’)” onmouseout=”czarny(‘this’)” >blablablablablablablabla</p>[/code]

and ideally should work as:

[code] function czerwony()
{
this.style.color=’#FF0000′;
}
function czarny()
{
this.style.color=’#000000′;
}

//u&#380;ycie:
<p onmouseover=”czerwony()” onmouseout=”czarny()” >blablablablablablablabla</p>[/code]

Tell me, you can do something like that, or not much? and used this as the last code tag does not indicate (object) who called the function? or from the body of the function is a simple pointer to the object that caused it, or just look like in the first code? Is it possible to pass a pointer to an object by the argument of the function (as in the second example)?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ReFreezedNov 12.2012 — You're so close! ?

function czerwony(element)
{
element.style.color='#FF0000';
}
function czarny(element)
{
element.style.color='#000000';
}

//use:
&lt;p onmouseover="czerwony(this)" onmouseout="czarny(this)" &gt;blablablablablablablabla&lt;/p&gt;
Copy linkTweet thisAlerts:
@morgarothauthorNov 13.2012 — oooo:eek:

thank you very much! ?
×

Success!

Help @morgaroth 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.19,
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,
)...