gpt4 book ai didi

javascript - 无法更改 jQuery Mobile 中动态生成的按钮文本

转载 作者:行者123 更新时间:2023-11-30 17:28:23 25 4
gpt4 key购买 nike

我使用 jquery mobile 动态创建按钮,就像在我的 phonegap 应用程序中一样。

var table = document.getElementById("skiTable");
var row = document.getElementById("skiparticulars");
var clone = table.rows[1].cloneNode(true);

var skiFile = clone.cells[0].getElementsByTagName('input')[0];
var skiformTitle = clone.cells[0].getElementsByTagName('input')[1];

skiFile.id = "skifile" + skiRowCount;
skiFile.value = "";
skiformTitle.id = "formTitle" + skiRowCount;

skiformTitle.value = "";
row.appendChild(clone);
skiRowCount++;

html代码是这样的

<table>
<tr>
<td>
<input type="hidden" id="skifile1" />
<input type="button" id="formTitle1"/>
</td>
<tr>
</table>

这里是更改按钮值的代码:

$("#skifile" + k).val(results.rows.item(j).ski_file);

$('#formTitle'+ k).val(results.rows.item(j).formTitle);
$("#formTitle"+k).button("refresh");
tried this also
//$("#formTitle" + k).prop('value',results.rows.item(j).formTitle).button("refresh");

但它永远不会改变值。

我引用了这个jquerymobile dynamically changing text for button issue

还有这个How to change the text of a button in jQuery?

最佳答案

jQuery Mobile 1.4 示例:

工作示例:http://jsfiddle.net/Gajotres/8x8HE/

JavaScript

$('#formTitle1').parent().html($('#formTitle1').parent().html() + 'Button text');

没有文本的按钮 HTML:

<div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
<input type="button" id="formTitle1">
</div>

带文本的按钮 HTML

<div class="ui-btn ui-input-btn ui-corner-all ui-shadow">
<input type="button" id="formTitle1">Button text
</div>

阅读this如果您想了解如何自定义 jQuery Mobile 元素,请阅读这篇文章。

jQuery Mobile 1.3 及以下示例:

工作示例:http://jsfiddle.net/Gajotres/wLzA7/

JavaScript

$('#formTitle1').parent().find('span span').html('Button text');

没有文本的按钮 HTML:

<div data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="c" data-disabled="false" class="ui-btn ui-shadow ui-btn-corner-all ui-btn-up-c" aria-disabled="false">
<span class="ui-btn-inner">
<span class="ui-btn-text"></span>
</span>
<input type="button" id="formTitle1" class="ui-btn-hidden" data-disabled="false"/>
</div>

带文本的按钮 HTML

<div data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="c" data-disabled="false" class="ui-btn ui-shadow ui-btn-corner-all ui-btn-up-c" aria-disabled="false">
<span class="ui-btn-inner">
<span class="ui-btn-text">Button text</span>
</span>
<input type="button" id="formTitle1" class="ui-btn-hidden" data-disabled="false"/>
</div>

关于javascript - 无法更改 jQuery Mobile 中动态生成的按钮文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23733514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com