Create image buttons in jquery mobile

淺唱寂寞╮ 提交于 2020-01-15 15:37:26

问题


Im trying to create a button in jquery mobile only with a image and no text, as far as able to do is to add a data-icon, But i have i feeling it could be done better.

<a onclick="newfunction();" data-icon="plus" data-iconpos="notext" ></a>

回答1:


You can create button with only images :

<img style="height: 40px; width: 40px;" id="newid" data-role="button" src="source\images\greenplus.png" data-iconpos="notext" data-theme="a" />  



回答2:


data-iconpos="notext" 

is indeed the right-way ahead for you to create a button with no text, but image only.

But i would change the onclick function that you have written. Instead of :

<a onclick="newfunction();" data-icon="plus" data-iconpos="notext" ></a>

Try out :

<a class="plus_button" data-icon="plus" data-iconpos="notext" ></a>

Since you are using jquery, use maximum jquery and your function would be :

$(".plus_button").click(function(){
   //something here
});

Cheers.



来源:https://stackoverflow.com/questions/18441710/create-image-buttons-in-jquery-mobile

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!