我有button
ul
<ul>
<li class="mix" category-1="" data-value="600.35" style="display:block;">
<figure>
<figcaption>
<h3>TK</h3>
<span>LHR</span>
<span>LHE</span>
<div class="clear"></div>
<span>Sat 28May16</span>
<span>
18:00
<span></span>
<span>
<i class="fa" fa-clock-o=""></i>
</span>
7361116644561201001
<div class="clear"></div>
<div class="price-night">
<span>1 Stop</span>
<span class="price-n">600.35 (£)</span>
</div>
<button class="info">Buy Now</button>
</span>
</figcaption>
</figure>
</li>
<li class="mix" category-1="" data-value="600.35" style="display:block;">
<figure>
<figcaption>
<h3>TK</h3>
<span>LHR</span>
<span>LHE</span>
<div class="clear"></div>
<span>Sat 28May16</span>
<span>
18:00
<span></span>
<span>
<i class="fa" fa-clock-o=""></i>
</span>
7361116644561201001
<div class="clear"></div>
<div class="price-night">
<span>1 Stop</span>
<span class="price-n">600.35 (£)</span>
</div>
<button class="info">Buy Now</button>
</span>
</figcaption>
</figure>
</li>
<ul/>
点击button
我想得到参考号,结束,总共3个值,我正在使用ASP.NET,所以我可以使用任何方法添加单个函数{{1调用但是如何获取oncick
li
值
答案 0 :(得分:0)
你必须迭代你的项目并抓住你需要的东西,这里有你的结构的例子:
$(".info").click(function(se,ev)
{
$.each($(".mix"),function(index,element)
{
alert($(element).attr("data-value"));
})
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul> <li class="mix" category-1="" data-value="600.35" style="display:block;"><figure><figcaption><h3>TK</h3><span>LHR</span> <span>LHE</span><div class="clear"></div><span>Sat 28May16</span> <span>18:00<span></span><span><i class="fa" fa-clock-o=""></i></span>7361116644561201001 <div class="clear"></div> <div class="price-night"><span>1 Stop</span><span class="price-n">600.35 (£)</span></div>
<button class="info">Buy Now</button></span></figcaption></figure></li>
<li class="mix" category-1="" data-value="600.35" style="display:block;"><figure><figcaption><h3>TK</h3><span>LHR</span> <span>LHE</span><div class="clear"></div><span>Sat 28May16</span> <span>18:00<span></span><span><i class="fa" fa-clock-o=""></i></span>7361116644561201001 <div class="clear"></div> <div class="price-night"><span>1 Stop</span><span class="price-n">600.35 (£)</span></div>
<button class="info">Buy Now</button></span></figcaption></figure></li>
&#13;
答案 1 :(得分:0)
您的问题很难遵循,但是假设您需要在单个函数中获取单击按钮的值,这可能会有所帮助。
$( "ul li" ).click(function() {
value = $(this).data("value");
alert( value );
});
&#13;