LOCKLOCK
LOCKLOCK

Reputation: 351

How to select font awesome icons in jQuery

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

Above is my code and I want to select this link in jQuery to add some effects. How can I select it?

Upvotes: 0

Views: 368

Answers (2)

jeffdill2
jeffdill2

Reputation: 4114

$('a.fa-plus-circle') will select all links that are using the fa-plus-circle class.

If you need something more specific to select that link and only that link, you'll need to add a more specific attribute to the link, such as an id.

Upvotes: 0

Tom
Tom

Reputation: 505

You can use any of these classes: fa fa-plus-circle fa-2x pull-right, e.g.: $('.fa-plus-circle') or $('.pull-right').

Choose that class, which does not repeat in other elements, that you don't want to be affected by your script.

You can also define context: $('.fa-plus-circle', '.parent-class-name'), which is the class name of one of the link parent elements in order to be more specific in choosing right link.

Upvotes: 1

Related Questions