首页 > 解决方案 > jQuery占位符文本一旦更改就不能再更改

问题描述

我想更改占位符的文本。我有些如何用 jQuery 改变它。运行代码后,我的新占位符是“输入收件人的电子邮件”但现在我想将占位符文本更改为“收件人的电子邮件”。我已经更新了代码。但占位符显示旧文本“输入收件人的电子邮件”。我不知道为什么。

jQuery(document).ready(function($) {
  $('#pwgc-to').attr("placeholder", "enter receiver’s email").val("").focus().blur();
    
})

以下代码已添加到 function.php

add_action( 'wp_enqueue_scripts', 'add_my_script' );
function add_my_script() {
    wp_enqueue_script(
        'change-placeholder', // name your script so that you can attach other scripts and de-register, etc.
        get_stylesheet_directory_uri() . '/js/change-placeholder.js', // this is the location of your script file
         array('jquery') // this array lists the scripts upon which your script depends
    );
}

标签: jquerywordpressplaceholder

解决方案


推荐阅读