jquery,从td单元格中的文本动态创建链接 [英] jquery, dynamically create link from text in td cell

查看:261
本文介绍了jquery,从td单元格中的文本动态创建链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个问题:
扫描图片,从内容创建链接(希望是php)

由于我在ms发布商工作,我可以删除地图图片并保持#' d盒子。只保存那些.htm我最终得到以下代码:

Since I'm working in ms publisher, I can remove the map image and just keep the #'d boxes. Saving just those as .htm I end up with the following code:

<!--[if gte vml 1]><![if mso | ie]><v:shape id="_x0000_s1039" type="#_x0000_t201" style='position:absolute;left:311.27pt;top:110.81pt;width:11.34pt;height:9pt; z-index:7;mso-wrap-distance-left:2.88pt;mso-wrap-distance-top:2.88pt; mso-wrap-distance-right:2.88pt;mso-wrap-distance-bottom:2.88pt' stroked="f" strokecolor="black [0]" insetpen="t" o:cliptowrap="t">
<v:stroke color2="white [7]">
<o:left v:ext="view" color="black [0]" color2="white [7]" weight="0"/>
<o:top v:ext="view" color="black [0]" color2="white [7]" weight="0"/>
<o:right v:ext="view" color="black [0]" color2="white [7]" weight="0"/>
<o:bottom v:ext="view" color="black [0]" color2="white [7]" weight="0"/>
<o:column v:ext="view" color="black [0]" color2="white [7]"/>
</v:stroke>
<v:shadow color="#ccc [4]"/>
<v:textbox inset="0,0,0,0">
</v:textbox>
</v:shape><![endif]><![endif]-->

<table v:shapes="_x0000_s1039" cellpadding=0 cellspacing=0 width=15 height=12 border=0 dir=ltr style='width:11.34pt;height:9.0pt;border-collapse:collapse; position:absolute;top:110.81pt;left:311.27pt;z-index:7'>
<tr>
<td width=15 height=12 bgcolor=white style='width:11.3385pt;height:9.0pt; padding-left:.1417pt;padding-right:.1417pt;padding-top:.1417pt;padding-bottom:.1417pt;background:white;border:solid blue .25pt'>
<p class=MsoNormal style='text-align:center;text-align:center'><span lang=en-US style='font-size:5.0pt;font-family:Arial;language:en-US'><span dir=ltr></span>185</span></p>
</td>
</tr>
</table>

我正在寻找(如上一个问题所示)从#中创建的链接单元格(在这种情况下它是185.我有太多不能手动执行此操作,所以我正在寻找一种方法来执行代码。

I'm looking (as in the previous question) to create links from the #'s in the cell (in this instance it is 185. I have far too many to manually do this on an ongoing basis, so am searching for a way to do it with code.

我发现这个代码使用jQuery,它应该从以下内容中获取文本:

I found this code with jQuery which should grab the text from the :

 $('#myTable tr').each(function() {
     var 
    $tds = $(this).find('td');
     if($tds.length != 0) {
     var 
    $currText = $tds.eq(0).text();

    alert('Curr Source Language: ' + $currText);

     }
     });

我不太确定如何实现上面的jQuery。我想要整个表是一个链接(不仅仅是内部的#)。所以如果'获取文本'有效,那么我想用整个表包装:


- e上面代码中的内容 -

I'm not quite sure how to implement the jQuery above either. I would like the entire table to be a link (not just the inner #'s). So if the 'get text' works, then I'd like to wrap the entire table with: -- everything inbetween as above code --

我希望这是有道理的。感谢您的任何建议。

I hope that makes some sense. Thanks for any suggestions.

推荐答案

您需要一种使用 lang在表格中查找值的方法= en-US 作为选择器。
然后你需要建立一个网址并更改页面

You need a way of finding the value in the table im using lang=en-US as a selector. Then you need to build a url and change the page

$(function (){
        // Assign click event on any table
        $('table').click(function(){
           // Get Value
           var val = $(this).find('[lang=en-US]').text();
           // Change Page
           window.location.href = "http://gotothislink_" + val + ".jpg"
        });
});

工作示例
http://jsfiddle.net/blowsie/tSMnd/

这篇关于jquery,从td单元格中的文本动态创建链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆