JSFiddle - React, Tailwind, and code Playground

by Zero Fx

HTML

<div class="x1">
  <img src="https://api.fnkr.net/testimg/350x200/00CED1/FFF/?text=find ID from JS">
</div>

<a id="lk1" href="#">test</a>
<button id="id1">~X~</button>


<script src="https://code.jquery.com/jquery-1.9.1.js" integrity="sha256-e9gNBsAcA0DBuRWbm0oZfbiCyhjLrI6bmqAl5o+ZjUA=" crossorigin="anonymous"></script>

CSS

* {
  padding: 0;
  margin: 0;
}

body {
  background-color: #ccc;
}

.x1 {
  width: 300px;
  height: 160px;
  margin: 0 auto;
  background-color: pink;
}

.x1 img {
  width: 100%;
  height: 100%;
}

.x2 {
  background-color: red !important;
}

#id1 {
  text-align: center;
  font-size: 34px;
  display: block;
  margin: 0 auto 0;
}

#lk1 {
  display: block;
  text-align: center;
  margin: 25px auto 25px;
  font: 32px "Tahoma";
}

JavaScript

$(document).ready(function() {
  var bd = $('body'); //кеширую body
  var bd_link = $('body a'); //кеширую все линки
  var lk_id = bd.find(bd_link).attr('id'); //кеширую атрибу ID

  $('#id1').click(function() {
    console.log(lk_id);
    if (lk_id !== 'ide') {
      console.log('555') // если lk_id равно ide - вивсести console_log 555
    };
  });
});