So my idea is to have title underlined and on hover it should disappear, but for some reason, I can’t find a way to do it properly.
Here is my code:
a.attr("href", jQuery('.underlined').attr("href"));
a.hover(
function() {
jQuery(this).css({"text-decoration":"none"});
},
function() {
jQuery(this).css({"text-decoration":"underline"});
}
);
Currently this is working like this: when a user loads the page the title is not underlined, and when user hovers over the title and move cursor away then that title is underlined and from then on it is working as it should.
Just to recap what I want:
- Title should be underlined by default
- When a user hovers over the title, underline should disappear
Any ideas?
Thank you.
Create a css rule based on a class (in style.css) , eg .newclass{text-decoration:underline;}. Then uses jQuery to addClass. , or removeClass to make the changes.
Add another class called something like ‘alreadyunderlined’ the the title, then before removing the ‘newclass’ simply check if the ‘alreadyunderlined’ class exists. That way you can be sure it only get’s changed the first time you hover over the title.
I hope that makes sense.
You should set
text-decoration: underline;
be default value, when page loads. By using CSS:or by using jQuery (javascript (but why?)) :