/    Sign up×
Community /Pin to ProfileBookmark

Onlick function

Hi,
I am new to coding and I am having problem passing background color to the javascript to store it in the cookie when someone clicks on the link and the div to change color to blue. Can anyone please let me know what I am doing wrong.

Is there any other way to pass the value for the background in the javascript and then call it. The code works when i pass it to the body of the page.

[CODE] <div id=”box1″ >
<a href=”#” onclick=”changecolor(‘box1’, ‘background-color:#00A’, ”)”>blue</a>
</div>[/CODE]

Thanks

GKz

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@bals28mjkSep 27.2007 — 
  • 1. There is no onlick event :rolleyes:


  • 2. onclick="javascript:document.body.style.backgroundColor='#00A'"
  • Copy linkTweet thisAlerts:
    @gkinsaneauthorSep 27.2007 — Thanks for your reply bals28mjk. I am able to change the color of the body but not this div box1. I need to pass the command like that so that I could save it in the cookie and read it. So someone can please help with this div box.

    Thanks

    Gkz
    Copy linkTweet thisAlerts:
    @bals28mjkSep 28.2007 — onclick="javascript:document.getElementById('box1').style.backgroundColor='#00A'"
    ×

    Success!

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