【问题标题】:How to insert a jQuery string into the placeholder element on an HTML form如何在 HTML 表单的占位符元素中插入 jQuery 字符串
【发布时间】:2013-11-01 02:54:26
【问题描述】:

这是来自Typewriter Effect with jQuery的分支问题

http://jsbin.com/araget/5

我想将数组中的每个字符串依次注入并清除到 html 表单上的“占位符”元素中。该函数当前将每个字符串写入并清除到一个空的 span 元素中。

没有使用 jQuery 的经验:/,有什么建议可以做这个吗?

【问题讨论】:

    标签: jquery dom


    【解决方案1】:

    使用.attr()

    $(element).attr('placeholder','Write text here'); 
    

    在jQuery中获取placeholder属性的值

    var placeholder_value = $(element).attr('placeholder'); 
    

    更好用 .prop()

    $(element).prop('placeholder','Write text here'); 
    

    在jQuery中获取placeholder属性的值

    var placeholder_value = $(element).prop('placeholder'); 
    

    Tats_innit评论

    阅读

    【讨论】:

    猜你喜欢
    • 2016-06-24
    • 1970-01-01
    • 2013-11-25
    • 2011-09-13
    • 1970-01-01
    • 1970-01-01
    • 2015-05-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多