Reputation: 23
The company I am working for handed me over a messy website ran using templates, so some elements in the website are automatically generated and are active links.
My main problem is that there are some elements on the site are active links that aren't suppose to be links at all. I was wondering if there is a way to remove the link from an html element using JQuery and maybe CSS?
this will help me tremendously, thanks in advance. I need to remove all href's from class 'slider'.
Here is some of my jquery, can someone please show me how to add it?
<script type="text/javascript">
$(document).ready(function(){
$("#productsLink").hover(function(){
$("#productsMenu").slideDown();
});
$("#productsLink, #productsMenu").hover(function(){
$("#productsLink").css("color","red");
});
$(".spacer", this).hover(function(){
$("#productsLink").css('color', 'white');
$("#productsMenu").slideUp();
$("#aboutLink").css('color', 'white');
$("#aboutMenu").slideUp();
});
});
</script>
Upvotes: 0
Views: 2002
Reputation: 7895
You can remove all href
attributes from links with class slider
with this code:
$('a.slider').removeAttr('href')
This will keep the content of the elements intact and just disables them as a link.
Upvotes: 1
Reputation: 11588
If you want to remove links with the class name slider
from the DOM:
$('a.slider').remove();
Upvotes: 1
Reputation: 119847
try unwrapping the sliders using .unwrap()
, assuming all these links have the class slider
and they are directly wrapped in an anchor tag.
$('.slider').unwrap()
Upvotes: 1
Reputation: 700342
CSS is no help here, it could only be used to hide elements completely.
You can use the replaceWith
method to turn specific a
elements into span
elements. Example:
$('a.something, a.someother').replaceWith(function(){
return $('<span/>').text($(this).text());
});
Upvotes: 0