开发者

How to have input field already have the 'clicked on' look without having to click it?

I want the input field to already have the clicked on look so when you look at the input field the '|' is already flashing without having someone having clicked on it?

It gives the search field a more welcoming touch

Here is my HTML for that field:

<input type="text" name="search" size="36" value="" 
style="background-color:white;border: 
solid 1px #ffffff; height: 30px; font-size:19px; font-family: HelveticaNeue-Light;
font-weight: 1;
vertical-align:9px;color:#bbb" 
onfocus="if(this.value == ''){t开发者_Go百科his.value = 
'';this.style.color='#363D42'}" />

Thanks!

James


If your intent is to have it actually focused as well, you could do that in javascript:

Add an ID to your input node: id="myID"

<script type="text/javascript">
    document.getElementById("myID").focus();
</script>

Also, HTML 5 has an autofocus attribute:

<input type="text" autofocus="autofocus" />


You focus() it:

document.getElementById('foo').focus();

To make it un-focused, you blur() it:

document.getElementById('foo').blur();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜