如何在初始化后动态更改按钮的 jQueryUI 图标?
<script>
$(function()
{
$( "#dynabutton" ).button(
{
icons:
{
primary: "ui-icon-gear"
},
text: false
});
$( "#swap" ).button(
{
icons:
{
primary: "ui-icon-locked"
},
text: true
}).click(function(event)
{
// change #dynabutton icon from
// "ui-icon-gear"
// to:
// "ui-icon-locked"
});
});
</script>
<div class="demo">
<button id="dynamic_button">Button with gear icon</button>
<button id="swap">Swap icons</button>
</div>
单击 #swap
按钮时,我想切换图标(jQueryUI 图标)与#dynabutton
相关联,从ui-icon-gear
到ui-icon-locked
。
但不知道支持吗?
<script>
$(function()
{
$( "#dynabutton" ).button(
{
icons:
{
primary: "ui-icon-gear"
},
text: false
});
$( "#swap" ).button(
{
icons:
{
primary: "ui-icon-locked"
},
text: true
}).click(function(event)
{
// change #dynabutton icon from
// "ui-icon-gear"
// to:
// "ui-icon-locked"
});
});
</script>
<div class="demo">
<button id="dynamic_button">Button with gear icon</button>
<button id="swap">Swap icons</button>
</div>
On click of the #swap
button, I want to switch the icon (jQueryUI icon) associated with #dynabutton
from ui-icon-gear
to ui-icon-locked
.
But I don't know if this is supported?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以调用
.button("option", options)
稍后设置选项(像其他 jQuery UI 小部件一样),包括图标:您可以在此处测试它。
You can call
.button("option", options)
to set options later (like other jQuery UI widgets), including the icons:You can test it here.