将图像添加到jquery按钮 [英] Add an image to the jquery button

查看:95
本文介绍了将图像添加到jquery按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将图像添加到jquery按钮。直到现在我在我的项目中使用了jquery ui按钮,我从图形团队获得了自定义图像,所以我想实现它们。

I am wondering how to add an image to the jquery button. Till now I was using the jquery ui button in my project and I got custom images from the graphics team, so I would like to implement them.

submit.button({ icons: {primary:'ui-icon-trash'}, text: false })

如何将自定义图像添加到此jquery按钮?

How to add custom image to this jquery button?

推荐答案

<button>Trash</button>
<style>
    .ui-button ​.ui-button-icon-primary {
        background: url('/my-custom-trash-image.png');
    }​
</style>
<script>
    $(function() {
        $('button').button({
            icons: {
                primary: 'ui-icon-trash'
            },
            text: false
        });
    });
</script>

不幸的是,您必须传入主要的有效值图标,即使它不会被使用。

Unfortunately you do have to pass in a valid value for the primary icon even though it won't be used.

实例 - http://jsfiddle.net/aMVrz/

这篇关于将图像添加到jquery按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆