有没有办法选择$(this).(“element”)?
我有一个名为 post 的父类,它根据帖子的类型具有特定的样式。示例:
CSS
/*CSS*/
li.post.quote {/*STYLE*/}
li.post.photo {/*STYLE*/}
HTML
<!--HTML-->
<li class="post quote">
<div class="someClass"> <!-- needs to be selected, but not by its class -->
</li>
<li class="post photo">
<div class="someOtherClass"> <!-- needs to be selected, but not by its class -->
</li>
我如何为每种类型的帖子选择“需要选择”,而不用在 jQuery 中为每种类型的帖子创建单独的函数?
更新: 它将是一个悬停动画,所以我需要它只选择悬停在帖子上的“需要选择”的内容。
i have a parent class called post and it has certain styles depending on the type of post. example:
CSS
/*CSS*/
li.post.quote {/*STYLE*/}
li.post.photo {/*STYLE*/}
HTML
<!--HTML-->
<li class="post quote">
<div class="someClass"> <!-- needs to be selected, but not by its class -->
</li>
<li class="post photo">
<div class="someOtherClass"> <!-- needs to be selected, but not by its class -->
</li>
how would i select "needs to be selected" for each type of post without creating seperate functions for each type of post in jQuery?
UPDATE:
its going to be a hover animation, so i need it to only select only the "needs to be selected" of the post that is being hovered over.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
也许我不明白你的意思,但你不能这样做 $('li.post div.needs_to_be_selected')
请注意,你正在你的 div 上创建 4 个类:needs、to、be 和 selected。
maybe I don't understand what you mean, but can't you do $('li.post div.needs_to_be_selected')
Note that you're creating 4 classes on your div there: needs, to, be, and selected.
不确定这是否是您要问的:
要获取所有类型帖子的 div:
要获取特定类型帖子的 div:
对,您的意思是悬停:
或者,
hover
可以取两个函数,一个用于进入,另一个用于离开:Not sure if this is what you're asking:
To get the div for all types of post:
To get the div for a particular type of post:
Right, you mean on hover:
Or,
hover
can take two functions, one for enter, the other for leave:是不是就这么简单:-
或者
希望这会有所帮助。
Isn't it just as simple as this:-
or even
Hope this helps.
$(".post").find(".需要选择").select()
?$(".post").find(".needs to be selected").select()
?