On hover, how to change div border

Greetings to all. I have a div on the mouse cursor, I want to change the border of the div. And on the other id changes dynamically. Please provide me any help for this. Thanks.

+3
source share
4 answers

can it help you

 <div onmouseover="somefunction(<?php echo $divid ?>)"> </div>


<script>
function somefunction(id)
{
document.getElementById(id).style.border="10px #FF0000 solid";
}
</script>
+3
source

It does not do the trick?

div {}
div:hover {border:1px solid #000000;}
+4
source

, , javascript, :hover. IE : , .

, div, jQuery . , , .

- :

$(function(){

  $('.yourclass').hover(
    function(){
       $(this).addClass('hovered');
    },
    function(){
       $(this).removeClass('hovered');
    }
  );

});

, , css .

, $(this).attr('id','newID');

+4

CSS provides a: hover selector that should work with a div.

eg:

div:hover { border: 1px solid #454545; }

As for dynamically changing id, I would use jQuery

jQuery(this).attr("id",newId);

If you post specific code, I can help with the syntax for your specific case ...

+3
source

Source: https://habr.com/ru/post/1776454/


All Articles