Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用JavaScript(polymer 1.0)更改纸张按钮的文本_Javascript_Onclick_Polymer - Fatal编程技术网

使用JavaScript(polymer 1.0)更改纸张按钮的文本

使用JavaScript(polymer 1.0)更改纸张按钮的文本,javascript,onclick,polymer,Javascript,Onclick,Polymer,我想将纸张按钮的文本从“修改”更改为“保存” 如何使用JavaScript实现这一点 我的纽扣 您可以通过以下方式直接使用via聚合物dom选择器: 此.$$msbutton.innerText=保存 msbutton是否在测试按钮元素中 您应该在单击时使用,而不是在单击时使用: 聚合物{ is:测试按钮, _changeText:函数{ var按钮=此。$.msbutton; button.textContent='新文本'; } }; 修改 我不确定我是否做对了抱歉,我是个初学者,但我将我

我想将纸张按钮的文本从“修改”更改为“保存”

如何使用JavaScript实现这一点

我的纽扣


您可以通过以下方式直接使用via聚合物dom选择器:

此.$$msbutton.innerText=保存

msbutton是否在测试按钮元素中

您应该在单击时使用,而不是在单击时使用:

聚合物{ is:测试按钮, _changeText:函数{ var按钮=此。$.msbutton; button.textContent='新文本'; } }; 修改
我不确定我是否做对了抱歉,我是个初学者,但我将我的函数更改为_changeText:function{this.$$msbutton.innerText=Save;}现在我得到一个错误:Uncaught ReferenceError:_changeText未在HTMLElement.onclick中定义。我对函数的引用是否有问题?在html中设置为on tap=_changeText,请告诉我是否已工作。double Dollar在性能上非常慢,因为它等于document.querySelectAll并返回第一个匹配项。相反,如果您已经知道元素的ID,您可以使用它。$.msbutton。@Vinod Louis Ya theonclick是问题所在。现在可以了。谢谢:-
<paper-button id="msbutton" onclick="_changeText">Modify</paper-button>
Polymer({
    is: "test-button",
    _changeText: function() {
    var button = document.getElementById('msbutton');
    //What comes here?
})