var url = "http://www.google.com";
$("#linkID").click(function() {
// ^When the element is clicked.
// Store classes in a string.
// If your word is present,
// then change the href.
var linkClasses = $(this).attr("class");
if (linkClass.indexOf("foxtail") >= 0) {
this.attr("href", url);
}
});
Request: "Hey!I was hoping to get some jquery/javascript help for a small script. I'll be testing this weekend but wondering if anyone had any further insight. Basically, I need to have a link check if a class has a certain word to redirect the link elsewhere. I have found a few tutorials but I haven't been able to do it myself quite yet or the descriptions in the documentation throws me off... Thanks in advance!"
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.