Good day. It is necessary that when you click on any dom element, its link in the div#id.class format is div#id.class . (c using jquery library). Tell me how you can implement it

    1 answer 1

     $('*').click(function(e) { e.stopPropagation() var _this = $(this).context; var tag = _this.tagName.toLowerCase(); var id = (i = _this.id) ? ('#' + i) : ''; var _class = (c = _this.className) ? ('.' + c) : ''; console.log(tag + id + _class); }) 
     #id { width: 50px; height: 50px; background: #eee; } #id2 { background: #c0c; } .class { width: 50px; height: 50px; background: #0cc; } div { float: left; margin: 10px; } 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="id"></div> <div class="class"></div> <div id="id2" class="class"></div> 

    • just what you need, thank you) - Semyon Shnurkov