2015-09-21 36 views
0
 = link_to content_tag(:i, nil, class: 'fa fa-plus-circle fa-2x pull-right'), my_path(format: :js), remote: true 

以上是我的代碼,我想在jQuery中選擇此鏈接以添加一些效果。我怎樣才能選擇它?如何在jQuery中選擇字體真棒圖標

回答

1

您可以使用以下任何類別:fa fa-plus-circle fa-2x pull-right, 例如:$('.fa-plus-circle')$('.pull-right')

選擇該類,在其他元素中不重複,不希望受到腳本影響。

您還可以定義上下文:$('.fa-plus-circle', '.parent-class-name'),它是鏈接父元素之一的類名,以便在選擇正確的鏈接時更具體。

0

$('a.fa-plus-circle')將選擇全部正在使用fa-plus-circle類的鏈接。

如果您需要更具體的選擇鏈接和只有該鏈接,您需要添加一個更具體的屬性鏈接,如id