Reputation:
I have the following:
$("#article").on('click',
'a[href^="/C"], a[href^="/Java"], a[href^="/T"]', function (event) {
Can this be simplified to not repeat the "href" so many times. Can I use a different kind of regular expression?
Upvotes: 3
Views: 80
Reputation: 30
At least make that one work
$("#article").on("click", 'a[href^="/C"]', 'a[href^="/Java"]', 'a[href^="/T"]', "function(event){}")
Upvotes: 0
Reputation: 55740
The best option would be is to give the all the three anchor tags a single class Name
..
$("#article").on('click', 'a.planguages', function (event) {
Or any other selector that is common for these three..
Otherwise you cannot remove the href
as that looks unique to the anchor tags in context.
Upvotes: 6