= link_to content_tag(:i, nil, class: 'fa fa-plus-circle fa-2x pull-right'), my_path(format: :js), remote: true
以上是我的代码,我想在jQuery中选择此链接以添加一些效果。我怎样才能选择它?如何在jQuery中选择字体真棒图标
= link_to content_tag(:i, nil, class: 'fa fa-plus-circle fa-2x pull-right'), my_path(format: :js), remote: true
以上是我的代码,我想在jQuery中选择此链接以添加一些效果。我怎样才能选择它?如何在jQuery中选择字体真棒图标
您可以使用以下任何类别:fa fa-plus-circle fa-2x pull-right
, 例如:$('.fa-plus-circle')
或$('.pull-right')
。
选择该类,在其他元素中不重复,不希望受到脚本影响。
您还可以定义上下文:$('.fa-plus-circle', '.parent-class-name')
,它是链接父元素之一的类名,以便在选择正确的链接时更具体。
$('a.fa-plus-circle')
将选择全部正在使用fa-plus-circle
类的链接。
如果您需要更具体的选择链接和只有该链接,您需要添加一个更具体的属性链接,如id
。