我如何遍历attr("rel")以获得我选择的那个. [英] How do I loop through attr("rel") to get the one I selected.
本文介绍了我如何遍历attr("rel")以获得我选择的那个.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个动态div,可创建图片点击或ipad点击.
I have a dynamic div create an image click or ipad tap.
<div></div> <div>
$("#pgNum").live("click, tap", function () {
var v = $("#book").turn("view");
var rel = $("#pgNum").attr("rel");
var spl = rel.split("x");// split the number from the text
var pgClicked = parseFloat(spl[0]);// selects the number. Here I
//need to loop and number selected should = becomes pgClicked.
$("#book").turn("page", parseInt(pgClicked));
$("#ContentTitle").fadeOut(1000);
$("#CView").val(v[0] + " - " + v[1]);
});
我的C#代码从数据库中加载了一个目录并将其放入其中:
My c# code loads the a table of contents from the databases and put them into this:
</div> <div></div> <div>
<div id="contents" class="clscontents" rel="1 Front Cover">
<ul>
<li> <a href="#" id="pgNum" rel="1 Front Cover"></a>l</i>
<li> <a href="#" id="pgNum" rel="2 IFC"></a>l</i>
<li> <a href="#" id="pgNum" rel="3 Table of Contents"></a>l</i>
<li> <a href="#" id="pgNum" rel="6 Visual Index"></a>l</i>
<li> <a href="#" id="pgNum" rel="24 Layering Light"></a>l</i>
<li> <a href="#" id="pgNum" rel="28 Clearing Crystal"></a>l</i>
</ul>
</div>
我需要的是当用户选择要转到的页面(如28清除Crystal转到页面28或6可视索引转到页面6)时,上下单击的代码相同,无论我单击哪个页面,都只能转到页面1.
What I need is when a user chooses a page to go like 28 Clearing Crystal goto page 28 or if 6 Visual Index goto page 6.With code below and above which is the same code it only goto page 1 no matter what page I click.
</div> <div>
$("#pgNum").live("click, tap", function () {
var v = $("#book").turn("view");
var rel = $("#pgNum").attr("rel");
var spl = rel.split("x");
var pgClicked = parseFloat(spl[0]);
$("#book").turn("page", parseInt(pgClicked));
$("#ContentTitle").fadeOut(1000);
$("#CView").val(v[0] + " - " + v[1]);
});
我需要以某种方式循环播放,然后
somehow I need to loop and what was
selected = pgClicked
推荐答案
(#pgNum").live("click,tap",function(){ var v =
("#pgNum").live("click, tap", function () { var v =
(#book").turn("view"); var rel =
("#book").turn("view"); var rel =
(#pgNum").attr("rel"); var spl = rel.split("x");//从文本中拆分数字 var pgClicked = parseFloat(spl [0]);//选择数字.我在这 //需要循环,所选的数字应=成为pgClicked.
("#pgNum").attr("rel"); var spl = rel.split("x");// split the number from the text var pgClicked = parseFloat(spl[0]);// selects the number. Here I //need to loop and number selected should = becomes pgClicked.
这篇关于我如何遍历attr("rel")以获得我选择的那个.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文