Hello, there is a code:

<a href="ссылка"> <div> <img src></img> <p>1</p> // Не ссылка Begin <p>2</p> // Не ссылка End <p>3</p> </div> </a> 

I need the whole div block to be a link, except <p>2</p> that the user can select the number 2, or even better, copy the data (number 2) without following the link, tell me how to do it correctly ?

  • What does php have to do with it? And what does copy the data mean? - Yaroslav Molchan
  • So that when pressed, the information was copied to the clipboard, located in <p> in line 7 of the code - Vitaly
  • Divide <a> into several, and that’s all, not? Although the possibility of this depends on the specific styles - andreymal

1 answer 1

 document.addEventListener('click', function (e) { debugger if (e.target.tagName === 'INPUT') { e.target.select(); e.preventDefault(); } }) 
 p { display: inline; } input { all: inherit; display: inline; width: 1ch; } 
 <a href="ссылка"> <div> <img> <p>1</p> <input type=text readonly value=2> <p>3</p> </div> </a> 

  • The first script is which programming language? And then immediately the second :) - Vitaly
  • javascript, css, html. Probably, without an input, it is also possible in the same way - I am too smart. - Qwertiy