how to add anchor tag inside cell of gridview using jquery

Posted by Klbaiju under jQuery on 7/18/2013 | Points: 10 | Views : 5262 | Status : [Member] | Replies : 1
Hi,

I want to add an anchor tag inside a gridview as per some condition

here is my code

$("#GridView1 tr td").filter(":not(td:first-child)").each(function () {


var cellText = $(this).text();

if ($.trim(cellText) == '')
{

$(this).css('background-color', 'LightGreen');


$(this).append("<a class='anchor1' href='#' title ='click here for book'>available</a>");
}
else
{

$(this).css('background-color', 'red');

var name = $(this).text();
$(this).append("<a class='anchor3' id='" + headertext + "-" + firstcelltext + "' href='#' >'"+name+"'</a>");

}
});

my requirement is in the else condition
celltext is booked
i want to add anchor tag inside the word booked like this
<a class='anchor3' href='#' >booked</a>");
i tried this code
$(this).append("<a class='anchor3' href='#'>'"+name+"'</a>");
I got the result as booked 'booked' means repeating the word.
i want to avoid this.
How to solve this.
Regards
Baiju




Responses

Posted by: Bandi on: 7/25/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
Hi Readers,

I just want to provide the link which has the solution for the above post so that someone can save their time & effort
http://forums.asp.net/t/1923179.aspx/1?how+to+add+anchor+tag+inside+cell+of+gridview+using+jquery


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response