使用jQuery动态添加href属性和表中的数据 [英] adding href attribute dynamically with data from a table using jquery
问题描述
我被困在这里,实际上是想使用list中项目的rel = shadowbox属性来更改标签的href值,该数据是从页面上的表中读取的. 这是我的html代码
i am stuck here, actually wanted to change the href values of the a tag with rel=shadowbox property of a items in list , where the data is read from the table on the page.. here is my html code
<div id="packgeImages">
<ul>
<li class="title"><a href="" rel="shadowbox"><img src="../../images/packages2/agra1thumb.jpg" alt="thumb1" /></a></li>
</ul>
</div>
这是我的jquery代码,用于捕获网格中的路径,然后将其追加到类.title
And here is my jquery code to capture the paths from grid and then append to the class .title
<script type="text/javascript">
$(document).ready(function () {
var $title = $('.title').attr("href"); //Unable to capture this
$('#fullImageGridView tr').each(function (i) {
if (!this.rowIndex) return; // skips first row
var bigSizeImagePath = this.cells[0].innerHTML;
// alert(bigSizeImagePath);
$title.eq(i - 1).append(bigSizeImagePath);
});
});
</script>
我想附加工作不正常,应将此更改链接到此$("a").attr("href", "http://www.google.com/")
我的意思是更改href属性,而不附加值??对吧?
I guess the appending is not working fine, the changes should be made linke this $("a").attr("href", "http://www.google.com/")
I mean changing the attribute of href and not appending the values?? right?
推荐答案
$('[rel=shadowbox]').attr('href', yourValue)
这篇关于使用jQuery动态添加href属性和表中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!