以"abc_google_"开头的所有ID的功能或"abc_facebook_" [英] Function for all the ids that starting with "abc_google_" or "abc_facebook_"
本文介绍了以"abc_google_"开头的所有ID的功能或"abc_facebook_"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为所有以以下内容开头的id设置点击功能:
I want to make a click function for all the ids that starting with:
abc_google_
abc_facebook_
abc_cnn_
我怎么能一行完成?
$('[id^="abc_google_"]').live("click", function () {
任何帮助表示赞赏!
推荐答案
您可以将多个选择器与,
组合在一起,就像在CSS中一样:
You can combine multiple selectors with ,
just like in CSS:
$('[id^="abc_google_"],[id^="abc_facebook_"],[id^="abc_cnn_"]').click(...)
或者,将处理程序委派给主体,并检查目标(或其任何父项)是否具有匹配的ID.
Alternatively, delegate the handler to the body and check if the target (or any parent thereof) has an ID that matches.
这篇关于以"abc_google_"开头的所有ID的功能或"abc_facebook_"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文