JQuery UI Highlight Effect - How can I use a border?

I'm trying to use highlighting in jQuery, but the color works, but the border doesn't work. How can I use the border?border: 2px solid #32a511

$("div").click(function () {
      $(this).effect("highlight", {
color: '#effdeb', border: '2px solid #32a511'}, 3000);
});

      

+3


source to share


1 answer


jQuery .effect()

just applies pre-built animations to your element. as Daniel points out, the highlight effect doesn't seem to work on the borders.

instead, you can use jQuery .animate()

to animate your div manually:



$("div").click(function() {
  $(this).animate({
    "background-color": '#effdeb',
    "border-color": "32a511",
    "border-width": "2px"
  }, 500);
});
      

div {
  width: 100px;
  height: 100px;
  display: inline-block;
  border: 1px solid black;
  box-sizing:border-box;
}
      

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<div></div>
<div></div>
<div></div>
<div></div>
      

Run codeHide result


+2


source







All Articles