The page has a link: <a href="#tab">Profile</a>
And the invisible block: <div id="tab"></div>
How in JS to make that by clicking on a link, first a certain condition is checked and only then a block is displayed? Or just ban the transition
Profile And the invisible block:
How in JS to make ...">The page has a link: <a href="#tab">Profile</a>
And the invisible block: <div id="tab"></div>
How in JS to make that by clicking on a link, first a certain condition is checked and only then a block is displayed? Or just ban the transition
Difficulty in what? Use return false; or preventDefault () (cancels the default action)
$(function(){ var val = 110; $('a').on('click', function(e){ if(val != 100){ // ΠΎΡΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΏΠ΅ΡΠ΅Ρ
ΠΎΠ΄ ΠΈΠ»ΠΈ Π½Π΅ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΠΊΠ°ΠΊΠΎΠ΅-Π»ΠΈΠ±ΠΎ Π΄Π΅ΠΉΡΡΠ²ΠΈΠ΅. e.preventDefault(); // ΠΈΠ»ΠΈ return false; } else { // Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΠΊΠ°ΠΊΠΎΠ΅-ΡΠΎ Π΄Π΅ΠΉΡΡΠ²ΠΈΠ΅ } }); }); Source: https://ru.stackoverflow.com/questions/382972/
All Articles