- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
来自以下网页代码:
(现在不要通读它 - 只需跳过它并看看我需要从以下代码中获取什么内容,然后您就可以返回到此代码。)
<table class="shop_table cart" cellspacing="0">
<thead>
<tr>
<th class="product-remove"> </th>
<th class="product-thumbnail"> </th>
<th class="product-name">Product</th>
<th class="product-price">Price</th>
<th class="product-quantity">Quantity</th>
<th class="product-subtotal">Total</th>
</tr>
</thead>
<tbody>
<tr class="cart_item">
<td class="product-remove">
<a href="http://dev123.MyDomain.com/cart/?remove_item=02e74f10e0327ad868d138f2b4fdd6f0&_wpnonce=2eef060511" class="remove" title="Remove this item">×</a>
</td>
<td class="product-thumbnail">
<a href="http://dev123.MyDomain.com/product/5-htp-power/">
<img width="90" height="90" src="http://dev123.MyDomain.com/wp-content/uploads/2014/04/product/2806-90x90.jpg" class="attachment-shop_thumbnail wp-post-image" alt="2806" />
</a>
</td>
<td class="product-name">
<a href="http://dev123.MyDomain.com/product/5-htp-power/">5-HTP Power</a>
</td>
<td class="product-price">
<span class="amount">$19.55</span>
</td>
<td class="product-quantity">
<div class="quantity">
<input type="number" step="1" name="cart[02e74f10e0327ad868d138f2b4fdd6f0][qty]" value="35" title="Qty" class="input-text qty text" size="4" />
</div>
</td>
<td class="product-subtotal">
<span class="amount">$97.75</span>
</td>
</tr>
<tr class="cart_item">
<td class="product-remove">
<a href="http://dev123.MyDomain.com/cart/?remove_item=6ea9ab1baa0efb9e19094440c317e21b&_wpnonce=2eef060511" class="remove" title="Remove this item">×</a>
</td>
<td class="product-thumbnail">
<a href="http://dev123.MyDomain.com/product/5-w/">
<img width="90" height="90" src="http://dev123.MyDomain.com/wp-content/uploads/2014/04/product/1120-90x90.jpg" class="attachment-shop_thumbnail wp-post-image" alt="1120" />
</a>
</td>
<td class="product-name">
<a href="http://dev123.MyDomain.com/product/5-w/">5-W</a>
</td>
<td class="product-price">
<span class="amount">$19.35</span>
</td>
<td class="product-quantity">
<div class="quantity">
<input type="number" step="1" name="cart[6ea9ab1baa0efb9e19094440c317e21b][qty]" value="104" title="Qty" class="input-text qty text" size="4" />
</div>
</td>
<td class="product-subtotal">
<span class="amount">$77.40</span>
</td>
</tr>
<tr class="cart_item">
<td class="product-remove">
<a href="http://dev123.MyDomain.com/cart/?remove_item=c16a5320fa475530d9583c34fd356ef5&_wpnonce=2eef060511" class="remove" title="Remove this item">×</a>
</td>
<td class="product-thumbnail">
<a href="http://dev123.MyDomain.com/product/7-keto/">
<img width="90" height="90" src="http://dev123.MyDomain.com/wp-content/uploads/2014/04/product/2922-90x90.jpg" class="attachment-shop_thumbnail wp-post-image" alt="2922" />
</a>
</td>
<td class="product-name">
<a href="http://dev123.MyDomain.com/product/7-keto/">7-Keto</a>
</td>
<td class="product-price">
<span class="amount">$38.25</span>
</td>
<td class="product-quantity">
<div class="quantity">
<input type="number" step="1" name="cart[c16a5320fa475530d9583c34fd356ef5][qty]" value="3" title="Qty" class="input-text qty text" size="4" />
</div>
</td>
<td class="product-subtotal">
<span class="amount">$114.75</span>
</td>
</tr>
<tr class="cart_item">
<td class="product-remove">
<a href="http://dev123.MyDomain.com/cart/?remove_item=182be0c5cdcd5072bb1864cdee4d3d6e&_wpnonce=2eef060511" class="remove" title="Remove this item">×</a>
</td>
<td class="product-thumbnail">
<a href="http://dev123.MyDomain.com/product/acidophilus/">
<img width="90" height="90" src="http://dev123.MyDomain.com/wp-content/uploads/2014/04/product/1666-90x90.jpg" class="attachment-shop_thumbnail wp-post-image" alt="1666" />
</a>
</td>
<td class="product-name">
<a href="http://dev123.MyDomain.com/product/acidophilus/">Acidophilus</a>
</td>
<td class="product-price">
<span class="amount">$15.95</span>
</td>
<td class="product-quantity">
<div class="quantity">
<input type="number" step="1" name="cart[182be0c5cdcd5072bb1864cdee4d3d6e][qty]" value="22" title="Qty" class="input-text qty text" size="4" />
</div>
</td>
<td class="product-subtotal">
<span class="amount">$31.90</span>
</td>
</tr>
<tr>
<td colspan="6" class="actions">
<div class="coupon">
<label for="coupon_code">Coupon:</label>
<input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="Coupon code" />
<input type="submit" class="button" name="apply_coupon" value="Apply Coupon" />
</div>
我需要捕获以下项目:
alt="2806"的 2806 部分
value="35"title="Qty"的35部分
alt="1120"的 1120 部分
value="104"title="Qty"的 104 部分
alt="2922"的 2922 部分
value="3"title="Qty"的第3部分
alt="1666"的 1666 部分
value="22"title="Qty"的22部分
我看过这个页面:
Javascript: How to loop through ALL DOM elements on a page?
以及此页面:
http://www.w3schools.com/js/js_htmldom_nodelist.asp
我有点不知所措。
我需要的是一些 javascript 代码,它将导致......一个包含以下内容的变量:
<input type="hidden" name="prodnum" value="2806" />
<input type="hidden" name="prodqty" value="35" />
<input type="hidden" name="prodnum" value="1120" />
<input type="hidden" name="prodqty" value="104" />
<input type="hidden" name="prodnum" value="2922" />
<input type="hidden" name="prodqty" value="3" />
<input type="hidden" name="prodnum" value="1666" />
<input type="hidden" name="prodqty" value="22" />
我将继续努力解决这个问题,看看我是否能自己解决这个问题,但可能性对我不利。
感谢您提供的任何帮助!
最佳答案
您可以使用三维 javascript 对象来做到这一点:
var stObj = {};
$('#mybutt').click(function(){
var cnt = 0;
$('.shop_table tbody tr:not(:last-child)').each(function(){
//alert( this.className );
cnt++;
stObj[cnt] = {};
$this = $(this);
var thImg = $this.find('.product-thumbnail a img').attr('alt');
//alert(thImg);
var prQty = $this.find('.product-quantity div input').val();
//alert(prQty);
stObj[cnt]['thImg'] = thImg;
stObj[cnt]['prQty'] = prQty;
});
alert( JSON.stringify(stObj) );
});
注释:
(1) 对象 stObj
是全局定义的(即在使用它的函数之外 - 上面 - )
(2) jQuery 选择器 tr:not(:last-child)
防止尝试在最后一个表行中查找 alt
和 value
(3) 在 jsFiddle 中,#tst
div 立即被代码隐藏。如果可见,它只是表明代码已损坏,而无需按任何按钮。
引用文献:
关于javascript - 解析当前页面的网页提交按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28955598/
这个问题与窗口处理或多个浏览器窗口的杂耍无关,而是关于在同一窗口中浏览 Web 应用程序的网页。我遇到这样的情况 1.我导航为屏幕 A->屏幕 x->屏幕 Y->屏幕 B 2.我需要捕获首次登录时屏幕
我有这个要求: The system will record the length of time the user displayed each page. 虽然在富客户端应用程序中微不足道,但我不
我在调试 JavaScript 网页时遇到问题。我遇到困难的地方是我标记 (...) 的地方。我收到未定义的错误。我是否将函数 countDown(start, Increment) 中的参数(即 s
需要一些帮助。我刚开始学习 HTML,今天一直在研究如何制作菜单,但在这样做时遇到了问题。 我似乎不知道如何在屏幕上居中显示菜单。 这就是我目前所拥有的; Home
我想通过单击按钮将小程序的任何参数发送到浏览器。 (HTML)。我知道按钮对象有一些方法,但不知道使用哪个。我怎样才能做到这一点?ps .: 我使用的是 jnlp 协议(protocol)。 类似于:
我应该使用Wikipedia的文章链接数据转储从组织的网站中提取代表性术语。 为此,我已经- 抓取并下载了该组织的网页。 (〜110,000) 创建了Wikipedia ID和术语/标题的字典。 (约
我的网页中包含 javascript 函数... function callFromAndroid(varName) { alert("call from android activated by
我想创建一个 Java 应用程序,允许用户导入网页并能够在程序中对其进行编辑。 导入网页将对其进行渲染,并且页面的组件(图像、文本等)将是可编辑或可拖动的,从而允许用户重新布局组件。 例如,用户可以加
当我们按下按钮时,我向 JFrame 添加了一个网页(网页在同一框架中打开)。效果很好。但我想向其中添加一个scrollPane,但是当我添加 JScrollPane jsp = new JScrol
我在使用 particles.js 时无法将图像居中。图像居中,但略微偏离中心。为什么要这样做,我如何才能将它居中? html particles.js demo CSS
我正在尝试在加载页面时播放音频,它应该非常简单但我无法完成。 问题是它没有播放,我尝试检查自动播放的状态(真/假),它说它在页面加载时播放,尽管它没有播放,还尝试制作一个将改变自动播放的功能状态为
我正在尝试显示用户从列表中选择的图像,但我在屏幕上看不到任何内容。 .container { position: relative; } .ce
这听起来有点奇怪,但我需要一些帮助,网页必须有一行必须包含三个部分,第一部分必须有 1 列的偏移量,并且部分之间的空间必须是 10px到目前为止,使用 Bootstrap 一切顺利。 现在第二行将有
这个问题在这里已经有了答案: Web and physical units (2 个答案) Div width in cm (inch) (6 个答案) 关闭 9 年前。
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
我想将我的 IPython 笔记本的宽度设置为 2500 像素,并且我希望它左对齐。我该怎么做? 我使用这段代码来应用我自己的 CSS: from IPython.core.display impor
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 7 年前。 Improve this q
我在 Word 中制作了一份文档,希望人们在其中添加自己的姓名以及他们的教学经验。我已将其保存为网页并发布到此处: http://epicforum.net/TS ...但操作部分实际上就是这样: h
这个问题在这里已经有了答案: Execute JS code after pressing the spacebar (5 个答案) 关闭 4 年前。
我正在开发一个只有两个页面的网站。 1.登录 2.首页 我正在使用 Angular 框架。 app.config(['$routeProvider', function ($routeProvider
我是一名优秀的程序员,十分优秀!