daveomcd
daveomcd

Reputation: 6565

jQuery: How do I remove a css border property from my div?

I'm trying to remove the border of a div, but no luck. I've commented out the code in my css and it is the correct property that I want to remove. Here is the code I'm using currently. The background-color change is working that's in the code below but the removeClass is not.

var tab = getURLParameter("tab");

// Disable the visual style of the button since it is disabled for this page.
if (tab == "Property") {
    $(".scrape-button").css('background-color', '#efefef');
    $(".scrape-button:hover").removeClass('border');
}

Any ideas? Thanks!

Upvotes: 6

Views: 44813

Answers (6)

C47
C47

Reputation: 661

Try this:

$(".scrape-button:hover").css('border','');

or

$('.scrape-button:hover').css('border', 'none');

Upvotes: 2

Vijay Verma
Vijay Verma

Reputation: 3698

Please try if you are using class--

$(".scrape-button:hover").attr('class','');

Upvotes: 1

Sushanth --
Sushanth --

Reputation: 55750

There is no :hover pseudo class in jQuery..

Try this

$('.scrape-button').hover(function() {
    $(this).removeClass('border')
}, function() {
    $(this).addClass('border')
});​

Check FIDDLE

Upvotes: 1

SNAG
SNAG

Reputation: 2113

$('.scrape-button:hover').css('border', 'none');

Try this

Upvotes: 4

coolxeo
coolxeo

Reputation: 563

The jQuery selector with hover pseudo class has no effect because there is no element in the page with hover state. I recommend you to try a different aproach

<script>
  var tab = getURLParameter("tab");

  if (tab == "Property") {
    $(".scrape-button").addClass("disabled")
  }
</script>
<style>
  .disabled {
    background-color: #EFEFEF;
  }

  .disabled:hover {
    border: none;
  }
</style>

Upvotes: 5

Adriano Carneiro
Adriano Carneiro

Reputation: 58625

Just remove the css property like this:

$(".scrape-button:hover").css('border','');

.removeClass() is used for removing a declared css class from element.

Upvotes: 13

Related Questions