javascript - After calling function I'm getting error saying undefined -
in table 1st column has tags href's , 3rd column has text. so, want save href's array respective 3rd column matches string , use later purpose. had tried following code nothing seems wrong me, can 1 assist me this.
function findimagelinks(){ var rows = jquery(".sortable tr.even").length + jquery(".sortable tr.odd").length; var imglinks = []; (i=0; i<rows; i++){ var conditionvalue =jquery(".sortable tr:eq(i+1) td:eq(3)").text(); if(conditionvalue == "some string"){ imglinks[i] = jquery(".sortable tr:eq(i+1) td:eq(0) a").attr('href'); } } console.log(imglinks); } findimagelinks();
your selector wrong. concatenate strings this
var conditionvalue = jquery(".sortable tr:eq(" + (i + 1) + ") td:eq(3)").text();
then code like,
(i = 0; < rows; i++) { var conditionvalue = jquery(".sortable tr:eq(" + (i + 1) + ") td:eq(3)").text(); if (conditionvalue == "some string") { imglinks[i] = jquery(".sortable tr:eq(" + (i + 1) + ") td:eq(0) a").attr('href'); } }
Comments
Post a Comment