小编man*_*its的帖子

与jQuery相反:eq()

有没有人知道是否存在某种选择器来从匹配的集合中选择元素,但是由指示的索引给出的元素.例如:

$("li").neq(2).size();
Run Code Online (Sandbox Code Playgroud)

假设有5个元素,最后一个语句将给你4个,并且将包含<li>DOM中的所有元素,但第二个元素.

javascript jquery jquery-selectors

35
推荐指数
4
解决办法
2万
查看次数

将Alpha通道添加到给定颜色

我有几个彼此相邻,我想用CSS设计风格.我想为背景应用各种各样的颜色,但我希望较低的颜色与不透明度降低相同,所以我想到了这个:

span.foo{
    background-color: rgba(0,0,0,1); /*or whatever*/
    color:white;
}

span.foo:last-child{
    background-color: rgba(*,*,*,0.5); /*just an example*/
}
Run Code Online (Sandbox Code Playgroud)

所以我想改变已经定义的背景的不透明度,而不是仅仅通过使用CSS3来影响文本的不透明度.

这可能吗?

css

14
推荐指数
4
解决办法
2万
查看次数

从jQuery Mobile中的可折叠集中删除图标

我一直在试图通过设置属性删除从一个可折叠的设置图标data-iconpos="none"div充当collapsible-set,但没有运气.它会删除它但仍留下某种阴影.

在此输入图像描述

jquery-mobile

2
推荐指数
2
解决办法
1万
查看次数

循环使用延迟对象和承诺

我有以下代码

    $.when(tableInsert("index.php/get/sync/riesgos", insert_riesgo, evalua.webdb.db, callback)).then(function(){
        update_records("riesgos");
        $.when(tableInsert("index.php/get/sync/estancias", insert_estancia, evalua.webdb.db, callback)).then(function(){
            update_records("estancias");
            $.when(tableInsert("index.php/get/sync/riesgosestancias", insert_riesgoestancia, evalua.webdb.db, callback)).then(function(){
                update_records("riesgosestancias");
            });
        });
    });
Run Code Online (Sandbox Code Playgroud)

我试图找到如何将它集成在for循环或$ .each循环中,以便它等待在下一次迭代之前完成的承诺.起初看起来三个调用更容易嵌套,但这只是一段代码,嵌套调用现在算了15个!

javascript jquery

1
推荐指数
1
解决办法
2862
查看次数

在ListView中只选择一个项目

我有一个带有自定义BaseAdapter的ListView,它可以呈现总线编号,来源和目的地.单击一行时,我希望原点和目标消失并显示两个按钮.我通过适配器上的clicklisteners完成了这项工作,但我需要它一次显示一个项目上的两个按钮(当选择不同的行时隐藏它们).

这很像Android的Twitter应用程序.我尝试使用MultiChoiceModeListener来做这件事,虽然我觉得它不是我想要的.

这是适配器的getView()方法上的clickListener的代码

busLabel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            LinearLayout parent = (LinearLayout) (v.getParent());
            parent.findViewById(R.id.bus_selector).setVisibility(View.GONE);
            parent.findViewById(R.id.bus_description).setVisibility(View.VISIBLE);
        }
    });
Run Code Online (Sandbox Code Playgroud)

布局的XML文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/bus_label"
        android:orientation="vertical"
        android:layout_height="@dimen/busline_height"
        android:layout_width="@dimen/busline_width">

        <TextView
            android:id="@+id/bus_number"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:singleLine="true"
            android:textSize="26sp"
            android:textStyle="bold"
            android:textColor="@color/regularbusfg"
            android:background="@color/regularbusbg"
            android:gravity="center" />

    </LinearLayout>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/bus_description"
        android:visibility="visible"
        android:orientation="vertical"
        android:paddingLeft="6dip"
        android:paddingRight="6dip"
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1">

        <TextView
            android:id="@+id/bus_origin"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:singleLine="true"
            android:textSize="18sp"
            android:textColor="@android:color/black"
            android:ellipsize="end"
            android:gravity="center_vertical" />

        <TextView
            android:id="@+id/bus_destination"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1"
            android:singleLine="true"
            android:textSize="18sp"
            android:textColor="@android:color/black"
            android:ellipsize="end"
            android:gravity="center_vertical" /> …
Run Code Online (Sandbox Code Playgroud)

android

0
推荐指数
1
解决办法
4332
查看次数