我有两个 h1标签,其内容为标题和第二标题。
我的问题是使用jquery both the h1 tags get activated
时。
我want the Second heading only to be used in jquery
。我该如何实现?
function animateText() {
TweenMax.from($('h1'), 0.8, {
scale: 0.4,
opacity: 0,
rotation: 15,
ease: Back.easeOut.config(4),
});
}
<h1 >Heading</h1>
<h1 >second heading</h1>
答案 0 :(得分:1)
您可以将id标签添加到元素:
<h1 id="not_using">Heading</h1>
<h1 id="use_this_one">second heading</h1>
然后通过其ID识别它们。
答案 1 :(得分:0)
TweenMax.from($('h1:contains(Second)')//...
答案 2 :(得分:0)
在这种情况下,您也可以使用adjacent sibling combinator
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
if (requestCode == REQUEST_CONTACT && data?.data != null) {
val contactUri = data.data;
val crContacts = contentResolver.query(contactUri, null, null, null, null);
crContacts.moveToFirst()
val id = crContacts.getString(crContacts.getColumnIndex(ContactsContract.Contacts._ID));
if (Integer.parseInt(crContacts.getString(crContacts.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
val crPhones = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
ContactsContract.CommonDataKinds.Phone.CONTACT_ID
+ " = ?", arrayOf(id), null)
crPhones.moveToFirst()
var phoneNo = crPhones.getString(
crPhones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER))
crPhones.close()
}
crContacts.close()
}
}
function animateText() {
TweenMax.from($('h1 + h1'), 0.8, {
scale: 0.4,
opacity: 0,
rotation: 15,
ease: Back.easeOut.config(4),
});
}
animateText();
答案 3 :(得分:-1)
如果您不想在第二个 h1 标记中使用任何ID,请按照以下说明使用 :eq() Selector :
function animateText() {
TweenMax.from( $('h1:eq(1)'), 0.8, { //You can also use $('h1').eq(1)
scale: 0.4,
opacity: 0,
rotation: 15,
ease: Back.easeOut.config(4),
});
}