最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Button text with multiple colors - Stack Overflow

programmeradmin5浏览0评论

I have an input button element which I would like to include the words "Take me there >" but I want to make the angle bracket a different color from the rest of the text.

Is this possible? I'm happy to use a javascript or jquery fix if necessary.

I have an input button element which I would like to include the words "Take me there >" but I want to make the angle bracket a different color from the rest of the text.

Is this possible? I'm happy to use a javascript or jquery fix if necessary.

Share Improve this question asked Jul 17, 2012 at 9:19 TomTom 13k50 gold badges153 silver badges247 bronze badges 1
  • 1 why not trying a div with CSS formatting and use as a button by using jQuery. – Riz Commented Jul 17, 2012 at 9:21
Add a ment  | 

2 Answers 2

Reset to default 8

How about this: http://jsfiddle/w3KHd/1/

Use a button with a span inside which sets the font color to whatever color you want. E.g.:

<button>Take me there <span style="color: red"> &gt; </span></button>

Update:

If you want to use the button as a submit button use:

<button type="submit">Take me there <span style="color: red"> &gt; </span></button>

If you can use <button> instead of <input type="button"> you can use "first-letter" Pseudo Class as below.
Your style class:

<style>
button:first-letter {
color:red;
}</style>

Button:

<button type="submit">&lt;Take me there ></button>
发布评论

评论列表(0)

  1. 暂无评论