我正在尝试使用jQuery来选择div,但忽略所有divs
选定div的子节点.divs
除了HREF
我匹配之外,没有任何其他方法可以识别它们.例如:
outerdiv = $('a[href^="http://bizmate."]').closest('div');
outerdiv.prepend("This was selected")
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>Won't be selected
<div>
Powered by <a href="http://bizmate.in">Bizmate</a>
<div>
Powered by <a href="http://bizmate.in">Bizmate</a>
<div>
Powered by <a href="http://bizmate.in">Bizmate</a>
</div>
</div>
</div>
</div>
<div>
<div>
Powered by <a href="http://bizmate.in">Bizmate</a>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
此代码选择所有divs
,包括孩子.如何将其限制为仅选择满足条件的最外层div而忽略divs
同时满足给定条件的子项?
编辑:
目前,该示例将给出:
将不会被选中
这位被选中的Bizmate 选择此项目被选中为Bizmate所有
这选择了Bizmate
这个选择了Bizmate
的电源
我希望结果如下:
将不会被选中
这位被Bizmate
提供动力由Bizmate
提供技术支持Bizmate
这个选择由Bizmate提供
我想创建一个CardView
具有ConstraintLayout
组织一些TextView
.
有时它会按预期显示,但有时会增加额外的空白区域,例如键盘关闭时会破坏布局.我有一个GIF下面显示CardView
工作,而不是在相同的时间段内工作.
相关的代码段CardView
如下.我wrap_content
试图保持CardView
我想要的大小,但它仍然扩大.
<android.support.v7.widget.CardView
android:id="@+id/cardView_game_cash"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="6dp"
app:cardCornerRadius="4dp"
app:contentPadding="6dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView_game_cashLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Total Cash"
app:layout_constraintLeft_toLeftOf="@+id/textView_game_cash"
app:layout_constraintRight_toRightOf="@+id/textView_game_cash"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView_game_totalProfitLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Total Profit"
app:layout_constraintLeft_toLeftOf="@+id/textView_game_totalProfit"
app:layout_constraintRight_toRightOf="@+id/textView_game_totalProfit"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView_game_profitLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Win Profit"
app:layout_constraintLeft_toLeftOf="@+id/textView_game_profit"
app:layout_constraintRight_toRightOf="@+id/textView_game_profit"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView_game_cash"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorAccent"
android:gravity="center"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/textView_game_totalProfit"
app:layout_constraintTop_toBottomOf="@+id/textView_game_cashLabel"
tools:text="TextView" />
<TextView
android:id="@+id/textView_game_totalProfit"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:gravity="center" …
Run Code Online (Sandbox Code Playgroud) xml android android-layout android-cardview android-constraintlayout
我有一个应用程序,可以通过使用 aWearableListenerService
和onPeerConnected
/来检测 android 穿戴设备何时断开连接onPeerDisconnected
。
似乎这些已被弃用,所以我现在正在尝试使用onCapabilityChanged
,但我无法调用此函数。我在我的服务清单中使用它。关于这些功能的文档不是很好。
<intent-filter>
<action android:name="com.google.android.gms.wearable.CAPABILITY_CHANGED" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)