0

Is it possible to switch the display:block part of #about{ with display:none part of #downloads with a OnClick?

#about {
    position:relative;
    -moz-border-radius: 5px;
    border-radius: 5px;
    width:800px;
    height:450px;
    margin-left:50px;
    margin-right:50px;
    border:solid 2px #000000;
    background-color:#448efc;
    margin-bottom:5px;
    display:block
}
#downloads {
    position:relative;
    -moz-border-radius: 5px;
    border-radius: 5px;
    width:800px;
    height:450px;
    margin-left:50px;
    margin-right:50px;
    border:solid 2px #000000;
    background-color:#448efc;
    margin-bottom:5px;
    display:none
}

heres my OnClick Code<a href="#downloads" onclick="somthing?"> im not sure if its possible do any of you know how?

1
  • Why do you want to change the css rule, instead change the class or just use jquery .show(), .hide() Commented Jun 16, 2013 at 3:24

5 Answers 5

3

You can change the css using jquery.

<a href="#downloads" onclick="$('#about').css("display", "none");">
Sign up to request clarification or add additional context in comments.

Comments

2

I would suggest something like this:

#about, #downloads {
    /* all of the CSS rules EXCEPT display here */
}
.hidden {display:none}

Then your HTML should be:

<div id="about">...</div>
<div id="downlaods" class="hidden">...</div>

Now your link can be:

<a href="#downloads" onClick="document.getElementById('about').className = 'hidden';
    document.getElementById('downloads').className = '';">Downloads</a>

Comments

0

It seems you are actually looking for jQuery toggle(). because it makes no sense keeping onclick event on the element which has already display: none.

<div id="about" onclick="$('#downloads').toggle()"></div>
<div id="downloads" onclick="$('#about').toggle()"></div>

Working Fiddle

Comments

0

Seems like you want to hide #about:

$('#downloads').click(function() {
    $('#about').hide();
});

With this, there's no need to add onclick attributes.

Comments

0

I had to change my quotesmarks, code below fully works for me....

<form action="uploadprofileaccept.php" 
class="dropzone" onclick="$('#imageform').css('display', 'none');">
</form>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.