输入字段文本不变

时间:2014-02-25 16:28:00

标签: javascript php wordpress

我正在尝试更改输入字段文本,它使用javascript onblur和onfocus,但保存后。我没有看到任何变化。以下是代码

<input type="text" name="EMAIL" class="required email" value="<?php _e('email','woothemes'); ?>"  id="mce-EMAIL" onfocus="if (this.value == '<?php _e('email','woothemes'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('email','woothemes'); ?>';}">

<input type="text" name="EMAIL" class="required email" value="<?php _e('your@email.com','woothemes'); ?>"  id="mce-EMAIL" onfocus="if (this.value == '<?php _e('your@email.com','woothemes'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('your@email.com','woothemes'); ?>';}">

由于术语<?php _e(); ?>用于wordpress中的翻译,我将其更改为echo,即便如此,我也看不到任何更改。
我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

onfocus="if (this.value == '<?php _e('your@email.com','woothemes'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('your@email.com','woothemes'); ?>';}">
                           ^_________^              ^__^        ^_____^   

请注意代码段中单引号的范围请尝试使用

onfocus="if (this.value == '<?php _e(\"your@email.com\",\"woothemes\"); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e(\"your@email.com\",\"woothemes\"); ?>';}">