Change:
if ($(this).href
To:
if (this.href
Or $(this).attr('href')
but former is better.
To read attributes, you need to use attr
(shorthand for attribute
)
This is what you should have:
if (this.href == "/Services/Cloud-Hosting") {
alert('hi');
}
else {
alert('no');
}
jQuery objects don't have an href
property. Just access the property of the HTMLAnchorElement using this.href
instead of creating a new jQuery object with $(this)
.
try this:
if ($(this).attr('href') == "/Services/Cloud-Hosting") {
See .attr() and try this:
$(this).attr('href') == "/Services/Cloud-Hosting"
instead