【问题标题】:Modify Uservoice Textarea placeholder修改 Uservoice Textarea 占位符
【发布时间】:2014-11-05 22:32:50
【问题描述】:

我尝试修改 UserVoice 的形式。

这里是小部件的 html 代码:

<article class="widget large-widget">
    <div class="viewport vertical-layout" data-viewport="" style="height: 325px;">
    <section class="pane instant-answers-omnibox-input-pane" style="display: block;">
    ....

        <form>

            <div class="pane-body" style="top: 48px; bottom: 119px; height: 158px;">
                <div data-stretch-vertical="" style="height: 158px;">
                    <textarea 
                         placeholder="Give feedback or ask for help…" 
                         data-autofocus="" 
                         data-search-input="" 
                         class="textbox textarea full-width full-height">
                    </textarea>
                </div>
           </div>

           ....

        </form>
     </section>
     </div>
</article>

我想修改textarea的占位符,但是无法访问。

示例:

jQuery('textarea').attr('class')   ->   <nothing>   (otherwise: 'textbox')

谢谢

【问题讨论】:

    标签: javascript jquery uservoice


    【解决方案1】:

    您正在尝试获取名为类而不是占位符的属性。

    修改html给textarea一个id:

    <textarea id="switch"
    placeholder="Give feedback or ask for help…" 
    data-autofocus="" 
    data-search-input="" 
    class="textbox textarea full-width full-height" />
    

    至于js代码,选择id而不是textarea:

    $("#switch").attr( "placeholder", "New value of placeholder");
    

    如果需要,您可以使用“if”块设置特定条件。

    【讨论】:

    • 是的,我对此进行了测试,但它不起作用。在我的例子中,它只是为了捕捉对象,但什么也没有。我的脚本不存在 uservoice 对象...
    • 我更新了代码...给该 textarea 一个 ID,然后选择该 ID。 console.log($("#switch"));将该对象转储到浏览器的控制台。
    • 是的,但是这个文本区域是由用户语音代码创建的,没有给出 ID!
    【解决方案2】:

    我刚刚注意到 uservoice 使用 iframe 作为小部件! 对不起!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-20
      • 2014-09-15
      • 2016-10-29
      • 1970-01-01
      • 2019-05-04
      • 2012-04-28
      • 1970-01-01
      相关资源
      最近更新 更多