I’m trying to add a selected class to a post in ruby on rails.
When I insert loc into the query a[href selector it doesn’t work even though loc is giving the correct url.
$(document).ready ->
jQuery ->
loc = location.href.substring(7)
loc = loc.substring(loc.indexOf("/"))
$('a[href$="posts?page=6"]').addClass("selected");
I want to put loc into the selector, like this
$('a[href$=""+loc]').addClass("selected");
But it’s not applying the selected class. Any help?
This is basic JavaScript string concatenation: