jquery - Clone Link on Column To Another Column in Table -


i want create td , link image after td:nth-child(2) , clone link a.link_topic_title

i have make script, link clone link on first row

$(document).ready(function () {     $('#preview_active').change(function () {         if ($(this).is(':checked')) {             var url_thread = $('.link_topic_title').attr("href");             var url_tooltip = "http://domain.com" + url_thread             $(".zebra thead tr th:first-child").attr('colspan', 4);             $('.zebra tbody tr td:nth-child(2)').after('<td class="span1 icon"><a href="' + url_thread + '"><img src="http://icons.iconarchive.com/icons/visualpharm/must-have/256/preview-icon.png" height="30px" width="25px" rel="tooltip" data-original-title="' + url_tooltip + '"/></a></td>');             $('.zebra tbody tr td:nth-child(3) img[rel=tooltip]').tooltip();         } else {             $(".zebra thead tr th:first-child").attr('colspan', 3);             $('.zebra tbody tr td:nth-child(3)').remove();         }     }); }); 

jsfiddle : http://jsfiddle.net/5vpra/2/

how clone list link on column column (create td)?

update

i have tried using each, managed pick links, not cloned each td,

$(document).ready(function () {     $('#preview_active').change(function () {         if ($(this).is(':checked')) {              classes = {};                $('.link_topic_title').each(function() {                $($(this).attr("href").split(' ')).each(function() {                 if (this !== '') {                  classes[this] = this;                 }                     });                });              tds = '';             $(".zebra thead tr th:first-child").attr('colspan', 4);             $('.zebra tbody tr td:nth-child(2)').after('<td class="span1 icon"></td>');              (class_name in classes) {              var url_tooltip = "http://domain.com" + class_name              tds += $('.zebra tbody tr td:nth-child(3)').append('<a href="' + class_name + '"><img src="http://icons.iconarchive.com/icons/visualpharm/must-have/256/preview-icon.png" height="30px" width="25px" rel="tooltip" data-original-title="' + url_tooltip + '"/></a>');                  $('.zebra tbody tr td:nth-child(3) img[rel=tooltip]').tooltip();           };         } else {             $(".zebra thead tr th:first-child").attr('colspan', 3);             $('.zebra tbody tr td:nth-child(3)').remove();         }     }); }); 

jsfiddle : http://jsfiddle.net/5vpra/3/

var url_thread = $('.link_topic_title').attr("href"); 

this line getting attr href first .link_topic_title element found. that's why created link have same url. think need loop in order know in row every time adding link. not expert , maybe there smoother way this.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -