0

我有这个代码->

var searchexampletxt = '<?php echo JText::_('SEARCH_EXAMPLE'); ?>';
Window.onDomReady(function(){

$('BLA_BLA').addEvent('focus',function(){
    if(this.value=='<?php echo JText::_('SEARCH_EXAMPLE');?>')
    {
    this.value="";
        }
    });

$('BLA_BLA').addEvent('blur',function(){
    if(this.value=='')
    {
    this.value="<?php echo JText::_('SEARCH_EXAMPLE');?>";
        }
    }); 

});

有人可以帮我吗,我怎样才能使“SEARCH_EXAMPLE”文本(默认显示在输入框中)例如颜色#CCCCCC,但我在输入框中写的文本例如是#333333?

谢谢干杯

4

1 回答 1

2

使用this.style.color="red"或使用十六进制代码this.style.color="#FF0000"

因此,对于您的示例:

  1. this.value="";添加后this.style.color="#CCCCCC";

  2. this.value="<?php echo JText::_('SEARCH_EXAMPLE');?>"添加后this.style.color="#333333";

于 2012-06-10T12:35:19.160 回答