gpt4 book ai didi

javascript - 如何在 onclick 按钮中获取计划详细信息

转载 作者:行者123 更新时间:2023-12-01 02:38:42 25 4
gpt4 key购买 nike

这里我有一个表格和三个按钮,假设如果我单击“立即注册”按钮意味着我已经获取了计划详细信息,例如

  1. 详细联系信息最多?
  2. 奖金联系方式最多可达?
  3. 区域大师协助:否?
  4. 通过短信提供详细联系信息?

以上数值我想取怎么取?我尝试过可以获取我选择的计划名称,但无法获取计划详细信息

  $(".payNow").on("click", function(e) {
var $list = $(this).closest(".pricing-table");
name = $list.find(".myTitle").text();

console.log(name);
});
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<body>
<body>
<div class="container-fluid plan-background" style="margin-top: 0%;padding-right: 0px;padding-left: 0px;">
<div class="container main_btm" style="padding-left: 0px;padding-right: 0px; ">

<div class="row top" style="margin-left: 0px;margin-right: 0px;margin-top:22px;">

<div class="col-md-5 col-sm-6 hidden-xs" class-align="right" style="margin-top: 10px;padding:left:23px; ">

</div>
<div class="col-md-3 col-sm-6 col-xs-12 mobile-property-list" style="margin-top: 10px; padding-left: 27px;"><h4 style="color:#fff;font-size:20px;"> Select Your Plan</h4></br> </div>
<div class="col-md-4 col-sm-0 hidden-xs"></div>

</div>

<div class="row mobile-filter" style="margin-top: 5px; margin-left: 0px;margin-right: 0px;margin-bottom:5%;" >

<div class="col-md-1"></div>
<div class="col-md-10 top-a rentListing" style="padding-left:0px;">

<section id="pricing-table">
<div class="row pricelistNew">
<div class="pricing">

<div class="col-md-4 col-sm-4 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Easy Plan </p>
<input type="hidden" value="1 " name="plan_Id" class="plan_Id">

<p class="pricing-rate">₹ 1000 <br><span>Including All Tax</span></p>

<a class="btn btn-custom payNow">Buy Now</a>

</div>

<div class="pricing-list">
<ul>
<li>Contacts details up to : 25</li>
<li>Bonus Contact details up to : 2</li>
<li>Area Master Assistance : No</li>
<li>Contact details through sms : Yes</li>
</ul>
</div>
</div>
</div>

<div class="col-md-4 col-sm-4 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Cool Plan </p>
<input type="hidden" value="2 " name="plan_Id" class="plan_Id">

<p class="pricing-rate">₹ 2000 <br><span>Including All Tax</span></p>

<a class="btn btn-custom payNow">Buy Now</a>

</div>

<div class="pricing-list">
<ul>
<li>Contacts details up to : 48</li>
<li>Bonus Contact details up to : 4</li>
<li>Area Master Assistance : Yes</li>
<li>Contact details through sms : Yes</li>
</ul>
</div>
</div>
</div>

<div class="col-md-4 col-sm-4 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Free Plan </p>
<input type="hidden" value="3 " name="plan_Id" class="plan_Id">

<p class="pricing-rate">₹ 0 <br><span>Including All Tax</span></p>

<a class="btn btn-custom payNow" style="">Enroll Now</a>


</div>

<div class="pricing-list">
<ul>
<li>Contacts details up to : 5</li>
<li>Bonus Contact details up to : 00</li>
<li>Area Master Assistance : No</li>
<li>Contact details through sms : Yes</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>

</div>

<div class="col-md-1 "></div>
</div>

</div>

最佳答案

您可以使用 HTML5 的数据属性并使用以下方式在 jQuery 中获取值。

 $(".payNow").on("click", function(e) {
var $list = $(this).closest(".pricing-table");
name = $list.find(".myTitle").text();
contact_upto = $list.find(".pricing-list ul").attr("data-contact-upto");
bonus_upto = $list.find(".pricing-list ul").attr("data-bonus-upto");
AMA = $list.find(".pricing-list ul").attr("data-AMA");
sms = $list.find(".pricing-list ul").attr("data-sms");
console.log(contact_upto);
});
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<body>
<body>
<div class="container-fluid plan-background" style="margin-top: 0%;padding-right: 0px;padding-left: 0px;">
<div class="container main_btm" style="padding-left: 0px;padding-right: 0px; ">

<div class="row top" style="margin-left: 0px;margin-right: 0px;margin-top:22px;">

<div class="col-md-5 col-sm-6 hidden-xs" class-align="right" style="margin-top: 10px;padding:left:23px; ">

</div>
<div class="col-md-3 col-sm-6 col-xs-12 mobile-property-list" style="margin-top: 10px; padding-left: 27px;"><h4 style="color:#fff;font-size:20px;"> Select Your Plan</h4></br> </div>
<div class="col-md-4 col-sm-0 hidden-xs"></div>

</div>

<div class="row mobile-filter" style="margin-top: 5px; margin-left: 0px;margin-right: 0px;margin-bottom:5%;" >

<div class="col-md-1"></div>
<div class="col-md-10 top-a rentListing" style="padding-left:0px;">

<section id="pricing-table">
<div class="row pricelistNew">
<div class="pricing">

<div class="col-md-4 col-sm-4 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Easy Plan </p>
<input type="hidden" value="1 " name="plan_Id" class="plan_Id">

<p class="pricing-rate">₹ 1000 <br><span>Including All Tax</span></p>

<a class="btn btn-custom payNow">Buy Now</a>

</div>

<div class="pricing-list">
<ul data-contact-upto="25" data-bonus-upto="2" data-AMA="No" data-sms="Yes">
<li>Contacts details up to : 25</li>
<li>Bonus Contact details up to : 2</li>
<li>Area Master Assistance : No</li>
<li>Contact details through sms : Yes</li>
</ul>
</div>
</div>
</div>

<div class="col-md-4 col-sm-4 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Cool Plan </p>
<input type="hidden" value="2 " name="plan_Id" class="plan_Id">

<p class="pricing-rate">₹ 2000 <br><span>Including All Tax</span></p>

<a class="btn btn-custom payNow">Buy Now</a>

</div>

<div class="pricing-list">
<ul data-contact-upto="48" data-bonus-upto="4" data-AMA="Yes" data-sms="Yes">
<li>Contacts details up to : 48</li>
<li>Bonus Contact details up to : 4</li>
<li>Area Master Assistance : Yes</li>
<li>Contact details through sms : Yes</li>
</ul>
</div>
</div>
</div>

<div class="col-md-4 col-sm-4 col-xs-12">
<div class="pricing-table">
<div class="pricing-header">
<p class="pricing-title myTitle">Free Plan </p>
<input type="hidden" value="3 " name="plan_Id" class="plan_Id">

<p class="pricing-rate">₹ 0 <br><span>Including All Tax</span></p>

<a class="btn btn-custom payNow" style="">Enroll Now</a>


</div>

<div class="pricing-list">
<ul data-contact-upto="5" data-bonus-upto="0" data-AMA="No" data-sms="Yes">
<li>Contacts details up to : 5</li>
<li>Bonus Contact details up to : 00</li>
<li>Area Master Assistance : No</li>
<li>Contact details through sms : Yes</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</section>

</div>

<div class="col-md-1 "></div>
</div>

</div>

关于javascript - 如何在 onclick 按钮中获取计划详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47711649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com