2014-02-25 110 views
0

我想改變輸入字段文本,使用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('[email protected]','woothemes'); ?>" id="mce-EMAIL" onfocus="if (this.value == '<?php _e('[email protected]','woothemes'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('[email protected]','woothemes'); ?>';}"> 

的術語<?php _e(); ?>用於翻譯WordPress的,我改成了迴音,即使這樣,我看不出有什麼變化。
我錯過了什麼?

+0

你有沒有嘗試刪除PHP和設置空值,看看是否改變了嗎? – adeneo

+0

作品[這裏](http://jsfiddle.net/GwMGx/1/) - 不是PHP,而是靜態值!我不確定,但你正在追求動態拼板! –

+0

請分享生成的html代碼 – Fallen

回答

0
onfocus="if (this.value == '<?php _e('[email protected]','woothemes'); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e('[email protected]','woothemes'); ?>';}"> 
          ^_________^    ^__^  ^_____^ 

注意代碼段單引號的範圍試試這個,

onfocus="if (this.value == '<?php _e(\"[email protected]\",\"woothemes\"); ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e(\"[email protected]\",\"woothemes\"); ?>';}"> 
+0

無論您在PHP標記中使用什麼引號,都不會輸出! – adeneo

+0

@adeneo:我的壞,沒有注意到。等待從OP生成的HTML或將刪除此 – Fallen