Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

HTML Changing background and text colour of menu item

KIlona

New Coder
Code:
<select onchange="window.location=this.value">
<option selected disabled>Buy the paperback</option>
<option value="http://www.amazon.com">Amazon</option>
<option value="http://www.yahoo.com">Blackwells</option>
<option value="http://www.yahoo.com">Book Depository</option>
<option value="http://www.yahoo.com">Barnes & Noble</option>
</select>

Hi,

I have a drop down selection list and I'd like to make just the disabled option (Buy the paperback) white text on a background of colour #008b8b. Can someone help me with that?

Also, I'd like the options, when selected, to open in a new window.

(I know my links don't match my options - not done yet!)

I'm a keen beginner so thanks in advance for any help.
 
Hiya and welcome 😀 how about this
HTML:
<select onchange="window.location=this.value">
<option class="disabled" selected disabled >Buy the paperback</option>
<option value="http://www.amazon.com">Amazon</option>
<option value="http://www.yahoo.com">Blackwells</option>
<option value="http://www.yahoo.com">Book Depository</option>
<option value="http://www.yahoo.com">Barnes & Noble</option>
</select>

[CODE lang="css" title="Add to the header in "]
.disabled{
color: #FFFFFF;
background-color: #008b8b;
}[/CODE]

as for the new window im not much help with Jquery 😀
 
Is this what you want -
HTML:
<select onchange="window.open(this.options[this.selectedIndex].value)">
    <option class="disabled">Buy the paperback</option>
    <option value="http://www.amazon.com">Amazon</option>
    <option value="http://www.yahoo.com">Blackwells</option>
    <option value="http://www.yahoo.com">Book Depository</option>
    <option value="http://www.yahoo.com">Barnes & Noble</option>
</select>
 
Is this what you want -
HTML:
<select onchange="window.open(this.options[this.selectedIndex].value)">
    <option class="disabled">Buy the paperback</option>
    <option value="http://www.amazon.com">Amazon</option>
    <option value="http://www.yahoo.com">Blackwells</option>
    <option value="http://www.yahoo.com">Book Depository</option>
    <option value="http://www.yahoo.com">Barnes & Noble</option>
</select>
Super star, thank you!
 
Hiya and welcome 😀 how about this
HTML:
<select onchange="window.location=this.value">
<option class="disabled" selected disabled >Buy the paperback</option>
<option value="http://www.amazon.com">Amazon</option>
<option value="http://www.yahoo.com">Blackwells</option>
<option value="http://www.yahoo.com">Book Depository</option>
<option value="http://www.yahoo.com">Barnes & Noble</option>
</select>

[CODE lang="css" title="Add to the header in "]
.disabled{
color: #FFFFFF;
background-color: #008b8b;
}[/CODE]

as for the new window im not much help with Jquery 😀
Thanks. This isn't working for me sadly. It's css, isn't it? I didn't understand the difference before but I don't think I can change the colours then because I don't have Wordpress Pro so I can't customise css, I don't think. :-(
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom