CSS 不透明度在 Phonegap 中不起作用

发布于 2025-01-04 17:48:40 字数 574 浏览 2 评论 0原文

我在手机间隙应用程序中使用 jQuery 禁用了一个按钮。 href 已删除,但按钮的不透明度不起作用,因此它看起来像一个损坏的按钮。有人可以让我知道更好的方法来解决这个问题或者更好的方法来完成这项工作吗?先感谢您!

这是我的代码:

jQuery.each(rolesArray, function() {
    if (this == "USER") {
        $('#disable-button').css( 'opacity', '.5');
        $('#disable-button').removeAttr('href');
    }

});

这是 HTML:

<div class="ui-block-b">
      <a href="#search" data-role="button" data-transition="flip" id="disable-button"><img src="images/logo.png" alt="Search" /></a>
    </div>

I have a button I have disabled using jQuery in my phone gap application. The href is removed BUT the opacity of the button is not working so it looks like a broken button. Can someone let me know a better way to go about this or a better way to have this work. Thank you in advance!

Here is my code:

jQuery.each(rolesArray, function() {
    if (this == "USER") {
        $('#disable-button').css( 'opacity', '.5');
        $('#disable-button').removeAttr('href');
    }

});

Here is the HTML:

<div class="ui-block-b">
      <a href="#search" data-role="button" data-transition="flip" id="disable-button"><img src="images/logo.png" alt="Search" /></a>
    </div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

清风不识月 2025-01-11 17:48:40

我在用动画显示蒙版时遇到了类似的问题:

opacity = $(maskDiv).css('opacity'); //read the opacity from CSS file
$(maskDiv).css('opacity', 0).animate({opacity: opacity}, 500); //animate fading

但是,虽然这在浏览器中有效,但方法 css() 在 PhoneGap 中返回错误的值,并且屏幕完全空白(蒙版不透明度=1)。
所以我只是通过将不透明度值硬编码到 JS 中来解决这个问题:

$(maskDiv).css('opacity', 0).animate({opacity: 0.5}, 500);

I had similar problem with displaying mask with animation:

opacity = $(maskDiv).css('opacity'); //read the opacity from CSS file
$(maskDiv).css('opacity', 0).animate({opacity: opacity}, 500); //animate fading

But while this works in browsers, method css() returns wrong value in PhoneGap and the screen gets completely blank (mask opacity=1).
So I simply fixed this with hardcoding the opacity value into JS:

$(maskDiv).css('opacity', 0).animate({opacity: 0.5}, 500);
看海 2025-01-11 17:48:40
jQuery.each(rolesArray, function() {
    if (this == "USER") {
        $("#yourButton").addClass('ui-disabled');
    }

});
jQuery.each(rolesArray, function() {
    if (this == "USER") {
        $("#yourButton").addClass('ui-disabled');
    }

});
夏夜暖风 2025-01-11 17:48:40

我认为您想要将不透明度设置为 0.5 的是“img”标签,而不是锚点。

jQuery.each(rolesArray, function() { 
    if (this == "USER") { 
        $('#disable-button').removeAttr('href').find('img').css('opacity', '.5'); 
    }     
}); 

I think that it is the "img" tag that you want to set the opacity to 0.5, not the anchor.

jQuery.each(rolesArray, function() { 
    if (this == "USER") { 
        $('#disable-button').removeAttr('href').find('img').css('opacity', '.5'); 
    }     
}); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文