Triggerlar matnini quyidagi tugmachani bosing

Men tugmachaning ostidagi matnning paydo bo'lishiga olib keladigan funksiyalarni o'rnatmoqchiman.

Misol uchun, "Hozir ro'yxatdan o'ting" tugmasini bosganingizda, "Siz a'zo ekansiz, ha yoki yo'qmi?" Degan tugma ostida matn paydo bo'ladi.

"Ha" va "Yo'q" siz qanday javob berganingizga qarab sizni boshqa sahifaga olib keladigan ishoratlar bo'ladi.

Hozircha tugma kodi (faqat HTML va uslublar bajarilgan):

Sign Up  
Now

Men bu kabi funktsionallik bilan yangitadim, shuning uchun har qanday yordam juda katta quvonch baxsh etadi!

Rahmat!

2

7 javoblar

href xususiyatini kerakli darajada sozlang.

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

$('#btn').click(function() {
  $('#modal').fadeIn();
});
a {
  display: block;
  text-decoration: none;
  color: white;
  background-color: #333;
  width: 100px;
  padding: 20px;
  border-radius: 5px;
  margin: 0 auto;
}

#modal {
  width: 300px;
  height: 120px;
  background-color: #ccc;
  border-radius: 5px;
  margin: 0 auto;
  display: none;
}

#modal h3 {
  text-align: center;
  padding: 10px;
}

#modal a {
  width: 50px;
  display: inline-block;
  text-align: center;
  margin: 0 auto;
  height: 10px;
  vertical-align: middle;
  line-height: 10px;
}

.btns {
  width: 200px;
  margin: auto;
}

a:hover {
  background-color: #666;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Sign Up Now

<div id='modal'>
  

Are you a member?

  <div class='btns'>
    Yes
    No
  </div>
</div>
</div> </div>

1
qo'shib qo'ydi

Quyidagi matnni yoki elementlarni ko'rsatish uchun onClick funksiyasidan foydalanishingiz mumkin.

Sign Up Now

0
qo'shib qo'ydi

JQuery'ni switch() funksiyasidan foydalanishingiz mumkin.

HTML:

<button id="member">
Are you Member ?
</button>

<div class="answer">
Yes
No </div>

JS:

$("#member").click(function() {
   $(".answer").toggle();
});

CSS:

.answer {
  display:none;
}

JsFiddle ustida ishchi namunasi .

Umid qilamanki bu yordam

0
qo'shib qo'ydi

Try this code. please vote if this code helpful to you

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

function execute(){
        var x =  document.getElementById('link_list');
        var y =document.getElementById('btn');
        if(x.style.visibility==="hidden"){
            y.style.visibility="hidden";
            x.style.visibility="visible";
        }
    }
<button onclick="execute()" id="btn">sign up</button>
<div id="link_list" style="visibility:hidden">
Are you a member, <button onclick="window.open('http://sparrolite.blogspot.in')">Yes</button> or  <button onclick="window.open('google.com')">no</button>
    </div>
</div> </div>
0
qo'shib qo'ydi

Bu erda aytilgan javoblarning aksariyati ham foydalanadi

  1. jQuery or,
  2. onclick attribute which is obtrusive javascript.

vanilya , noaniq JavaScript yordamida kerakli xatti-harakatga qanday erishish mumkin.

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

window.onload = function() {
  var button = document.querySelector('.ticket-button');
  var info = document.querySelector('.info');

  info.style.display = 'none';
  var dispalyInfo = false;

  button.onclick = function(e) {
    e.preventDefault(); /* prevent page from navigating to a new page onclick */
    if (dispalyInfo) {
      info.style.display = 'none';
      dispalyInfo = false;
    } else {
      info.style.display = 'initial';
      dispalyInfo = true;
    }
  }
}
.ticket-button {
  display: block;
}
Sign Up Now
Are you a member, yes or no?
</div> </div>

Manbalar:

0
qo'shib qo'ydi

@Peter Howell aytganidek, matnni ko'rsatish uchun onClick funksiyasidan foydalanishingiz mumkin. jQuery bilan buni amalga oshirishning juda oddiy usuli.

<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code">

$(function() {
                        $('.link').on('click', function() {
                                $('.span').addClass('open');
      });
});
.span {
  display: none;
}
.open {
  display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Click me
I'm hidden!
</div> </div>

Working fiddle: https://jsfiddle.net/3gr03yzn/4/

0
qo'shib qo'ydi

oddiy usul:

Sign Up Now

<script>
function confirmSignup(){
  if(confirm("Are you sure?"))
  {
    window.location.href="http://somelocation.com/sign-up";
  }
}
</script>
0
qo'shib qo'ydi
Javascript UZB
Javascript UZB
99 ishtirokchilar

@js_uzb @vuejs_uz @react_uz @nodejs_uz @angular_uz @ngTashkent @yiiframework_uz @laravel_uz @linux_uzbek @python_uz @swift_uzb —————— @uzdevgroup @UzGeeksGroup ——— @UzDev_Jobs @jobs_uzb

PhP |BotsUz
PhP |BotsUz
93 ishtirokchilar

Phpni o'rganishni Hohlasangiz https://t.me/joinchat/AAAAAE-KRc5dd5tPMmGmWA A'zo bo'lin