我有一个包含多个类的元素列表,例如:
<input class="etape btn-info others">
<input class="etape btn-inverse others">
<input class="etape btn-danger others">
如何编写允许我执行以下操作的 jQuery 代码……
$(".etape").click(function(){
$(this).get("the class that starts with btn-")
// in order to store this value in a variable to reuse it later
});
原文由 fatiDev 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以使用正则表达式或
split
类名。http://jsfiddle.net/LQPh6/