开发者

adding jquery onto a link

开发者 https://www.devze.com 2023-01-13 19:35 出处:网络
I\'m having some trouble adding a javascript variable onto the end of my link here\'s my code var locid = $.trim($(this > \'.locid\'开发者_JAVA技巧).text());

I'm having some trouble adding a javascript variable onto the end of my link here's my code

var locid = $.trim($(this > '.locid'开发者_JAVA技巧).text());

$(this).prepend('<a class="booknow2" href="../../availability/default.aspx?propid=' + locid + '"><span>Check availability &raquo;</span></a>');

Any help would be appreciated

Thanks

Jamie


To get a direct child when you already have another element, use .children(), like this:

var locid = $.trim($(this).children('.locid').text());

You can't really use $(this ...anything), you can however use $(this).something(), and that .something() could be any of the tree traversal functions to move around.

0

精彩评论

暂无评论...
验证码 换一张
取 消